Skip to main content

externalSerenityFixtures

Serenity/JS-specific Playwright Test fixtures injected into your test scenarios.

Example test scenario

import { Ensure, equals } from '@serenity-js/assertions'
import { describe, it, test } from '@serenity-js/playwright-test'
import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'

describe(`Recording items`, () => {

test.use({
defaultActorName: 'Serena',
crew: [
Photographer.whoWill(TakePhotosOfFailures),
],
})

describe(`Todo List App`, () => {

it(`should allow me to add a todo item`, async ({ actor }) => {
await actor.attemptsTo(
startWithAnEmptyList(),

recordItem('Buy some milk'),

Ensure.that(itemNames(), equals([
'Buy some milk',
])),
)
})
})
})

Learn more

Index

Properties

externalserenity

serenity: Serenity

Retrieves the root object of the Serenity/JS framework.

externalplatform

platform: { name: string; version: string }

Name and version of the operating system that Playwright Test worker process runs on.


Type declaration

  • externalname: string
  • externalversion: string

externalactors

actors: Cast

A cast of Serenity/JS actors to be used instead of the default cast when instantiating actor and invoking actorCalled.

Overriding the default cast of Serenity/JS actors

import { Cast, TakeNotes } from '@serenity-js/core'
import { Ensure, equals } from '@serenity-js/assertions'
import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
import { describe, it, test } from '@serenity-js/playwright-test'

describe(`Recording items`, () => {

test.use({
defaultActorName: 'Serena',
actors: ({ browser, contextOptions }, use) => {
const cast = Cast.where(actor =>
actor.whoCan(
BrowseTheWebWithPlaywright.using(browser, contextOptions),
TakeNotes.usingAnEmptyNotepad(),
)
)

// Make sure to pass your custom cast to Playwright `use` callback
use(cast)
},
})

describe(`Todo List App`, () => {

it(`should allow me to add a todo item`, async ({ actor }) => {
await actor.attemptsTo(
startWithAnEmptyList(),

recordItem('Buy some milk'),

Ensure.that(itemNames(), equals([
'Buy some milk',
])),
)
})
})
})

externalactorCalled

actorCalled: (name: string) => Actor

Uses the provided cast of actors to instantiate an Actor called name and inject it into a test scenario.

Retrieves an existing actor if one has already been instantiated.

Learn more


Type declaration

    • Parameters

      • externalname: string

      Returns Actor

externalactor

actor: Actor

Default actor injected into a test scenario.

Using actor fixture is equivalent to invoking actorCalled with defaultActorName.

Learn more