Re-configures Serenity/JS with a new cast of actors
you want to use in any subsequent calls to actorCalled.
This function is an alias for Serenity.engage,
which provides an alternative to calling Actor.whoCan directly in your tests
and is typically invoked in a "before all" or "before each" hook of your test runner of choice.
configure vs engage
Calling engage replaces the currently configured cast of actors,
but doesn't affect any other configuration.
If you want to reset the Serenity/JS configuration completely, use configure instead.
If your implementation of the cast interface is stateless,
you can invoke this function just once before your entire test suite is executed, see
import{ Actor, Cast }from'@serenity-js/core'; classActorsimplementsCast{ prepare(actor: Actor){ return actor.whoCan( // ... abilities you'd like the Actor to have ); } } engage(newActors());
Re-configures Serenity/JS with a new cast of actors you want to use in any subsequent calls to
actorCalled
.This function is an alias for
Serenity.engage
, which provides an alternative to callingActor.whoCan
directly in your tests and is typically invoked in a "before all" or "before each" hook of your test runner of choice.Calling
engage
replaces the currently configured cast of actors, but doesn't affect any other configuration. If you want to reset the Serenity/JS configuration completely, useconfigure
instead.If your implementation of the cast interface is stateless, you can invoke this function just once before your entire test suite is executed, see
beforeAll
in Jasmine,before
in Mocha,BeforeAll
in Cucumber.jsHowever, if your cast holds state that you want to reset before each scenario, it's better to invoke
engage
before each test using:beforeEach
in JasminebeforeEach
in Mocha,Before
in Cucumber.jsEngaging a cast of actors
Using with Mocha test runner
Using with Jasmine test runner
Using with Cucumber.js test runner
Engage
Actors
before each test scenario:Engage
Actors
before scenarios with specific tags:Using with Playwright Test runner
Serenity/JS Playwright Test module will configure the cast on your behalf, so you don't need to call
engage
.Learn more
Actor
Cast
Serenity.engage