WithStage
Makes the Stage object setup in your test runner configuration visible to test steps or test scenarios.
When using Cucumber, the Stage is typically set up using the Cucumber World Constructor.
When using Jasmine, the Stage is typically set up in the beforeEach
step.
this class was deprecated. Please use serenity.actor() and serenity.actorInTheSpotlight() instead
Examples:
Usage with Cucumber.js
// features/support/configure_serenity.ts
import { WithStage } from '@serenity-js/core';
import { setWorldConstructor } from 'cucumber';
setWorldConstructor(function (this: WithStage, { parameters }) {
this.stage = serenity.callToStageFor(new SomeImplementationOfTheCastInterface());
});
// features/step_definitions/some.steps.ts
import { WithStage } from '@serenity-js/cucumber';
Given(/(.*?) is a registered customer/, function (this: WithStage, actorName: string) {
return this.stage.actor(actorName).attemptsTo(
);
});
Usage with Jasmine
// spec/some.spec.ts
import { serenity, WithStage } from '@serenity-js/core';
describe('Using the Stage', () => {
beforeEach(function (this: WithStage) {
this.stage = serenity.callToStageFor(new SomeImplementationOfTheCastInterface());
});
it('makes it easy to access the Actors', function(this: WithStage) {
return this.stage.theActorCalled('Barry').attemptsTo(
// tasks
);
})
});