externalSerenityFixtures
Index
Properties
externaldefaultActorName
Configures the name given to the default Serenity/JS actor
injected into a test scenario.
Learn more
- Declaring a Serenity/JS test scenario
SerenityFixtures
externalcrew
Configures the stage crew members to be instantiated in Playwright Test worker processes.
By default, Serenity/JS registers a Photographer
.whoWill(TakePhotosOfFailures
),
so that any test failures are automatically accompanied by a screenshot.
If you prefer a different behaviour, you can configure the crew
with an empty array to disable taking screenshots altogether (crew: []
),
or with a Photographer
who uses a different PhotoTakingStrategy
, like to TakePhotosOfInteractions
.
Example
// playwright.config.ts
import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
import { defineConfig } from '@playwright/test'
export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
use: {
crew: [
[ '@serenity-js/web:Photographer', { strategy: 'TakePhotosOfFailures' } ]
],
},
});
Learn more
externalcueTimeout
Sets the cueTimeout
to a given duration or a numeric value in milliseconds.
Defaults to 5 seconds.
Learn more
externalinteractionTimeout
The maximum default amount of time allowed for interactions such as Wait.until
to complete.
Defaults to 5 seconds, can be overridden per interaction.
Learn more
externalextraContextOptions
Convenience properties to be used with the ability
to BrowseTheWebWithPlaywright
,
in addition to Playwright BrowserContextOptions:
Using extraContextOptions
with the default cast of Serenity/JS actors
// playwright.config.ts
import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
import { defineConfig } from '@playwright/test'
export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
use: {
extraContextOptions: {
defaultNavigationTimeout: 30_000,
}
// Since `actors` property is not defined,
// `extraContextOptions` will be passed to the default cast of Serenity/JS actors
// and injected into the ability to `BrowseTheWebWithPlaywright`
// that each actor receives.
},
})
Using extraContextOptions
with a custom cast of Serenity/JS actors
// playwright.config.ts
import type { SerenityFixtures, SerenityWorkerFixtures } from '@serenity-js/playwright-test'
import { defineConfig } from '@playwright/test'
export default defineConfig<SerenityFixtures, SerenityWorkerFixtures>({
use: {
extraContextOptions: {
defaultNavigationTimeout: 30_000,
}
// Custom cast of actors receives the default `contextOptions` and
// the `extraContextOptions` with the additional Serenity/JS properties.
actors: async ({ browser, contextOptions, extraContextOptions }, use) => {
const cast = Cast.where(actor => actor.whoCan(
BrowseTheWebWithPlaywright.using(browser, contextOptions, extraContextOptions),
TakeNotes.usingAnEmptyNotepad(),
))
await use(cast)
},
},
})
Learn more
externalactors
A cast of Serenity/JS actors to be used instead of the default cast
when instantiating actor
and invoking actorCalled
.
When you use @serenity-js/playwright-test
test APIs, Serenity/JS already provides a default cast of actors for you.
Each one of the default actors receives abilities to BrowseTheWebWithPlaywright
and TakeNotes.usingAnEmptyNotepad
.
The default abilities should be sufficient in most web testing scenarios. However, you might want to override this default configuration when you need your actors to interact with REST APIs, manage local servers, start with a notepad that has some initial state, or receive custom abilities.
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({
extraContextOptions: {
defaultNavigationTimeout: 30_000,
},
defaultActorName: 'Serena',
actors: async ({ browser, contextOptions, extraContextOptions }, use) => {
const cast = Cast.where(actor =>
actor.whoCan(
BrowseTheWebWithPlaywright.using(browser, contextOptions, extraContextOptions),
TakeNotes.usingAnEmptyNotepad(),
)
)
// Make sure to pass your custom cast to Playwright `use` callback
await 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',
])),
)
})
})
})
#### Learn more
- Declaring a Serenity/JS [test scenario](/api/playwright-test/function/it/)
- [`SerenityFixtures`](/api/playwright-test/interface/SerenityFixtures/)
externalactor
Default actor
injected into a test scenario.
Using actor
fixture is equivalent to invoking actorCalled
with defaultActorName
.
Learn more
actorCalled
defaultActorName
- Declaring a Serenity/JS test scenario
Serenity/JS-specific Playwright Test fixtures injected into your test scenarios.
Configuring Serenity/JS using a test file
Configuring Serenity/JS using Playwright configuration file
Learn more
PlaywrightTestConfig
Cast
SerenityFixtures