import type { SerenityConfig } from './config'; import type { ErrorOptions, RuntimeError } from './errors'; import type { DomainEvent, EmitsDomainEvents } from './events'; import { Path } from './io'; import type { ActivityDetails, CorrelationId } from './model'; import type { Actor, Timestamp } from './screenplay'; import { Clock } from './screenplay'; import type { Cast } from './stage/Cast'; /** * @group Serenity */ export declare class Serenity implements EmitsDomainEvents { private readonly clock; private static defaultCueTimeout; private static defaultInteractionTimeout; private static defaultActors; private stage; private readonly fileSystem; private outputStream; private readonly classLoader; private readonly workingDirectory; /** * @param clock * @param cwd */ constructor(clock?: Clock, cwd?: string); /** * Configures Serenity/JS. Every call to this function * replaces the previous configuration provided, * so this function should be called exactly once * in your test suite. * * @param config */ configure(config: SerenityConfig): void; /** * Re-configures Serenity/JS with a new {@apilink Cast} of {@apilink Actor|actors} * you want to use in any subsequent calls to {@apilink actorCalled}. * * For your convenience, use {@apilink engage} function instead, * which provides an alternative to calling {@apilink Actor.whoCan} directly in your tests * and is typically invoked in a "before all" or "before each" hook of your test runner of choice. * * If your implementation of the {@apilink Cast} interface is stateless, * you can invoke this function just once before your entire test suite is executed, see * - [`beforeAll`](https://jasmine.github.io/api/3.6/global.html#beforeAll) in Jasmine, * - [`before`](https://mochajs.org/#hooks) in Mocha, * - [`BeforeAll`](https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/hooks.md#beforeall--afterall) in Cucumber.js * * However, if your {@apilink Cast} holds state that you want to reset before each scenario, * it's better to invoke `engage` before each test using: * - [`beforeEach`](https://jasmine.github.io/api/3.6/global.html#beforeEach) in Jasmine * - [`beforeEach`](https://mochajs.org/#hooks) in Mocha, * - [`Before`](https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/hooks.md#hooks) in Cucumber.js * * ## Engaging a cast of actors * * ```ts * import { Actor, Cast } from '@serenity-js/core'; * * class Actors implements Cast { * prepare(actor: Actor) { * return actor.whoCan( * // ... abilities you'd like the Actor to have * ); * } * } * * engage(new Actors()); * ``` * * ### Using with Mocha test runner * * ```ts * import { beforeEach } from 'mocha' * * beforeEach(() => engage(new Actors())) * ``` * * ### Using with Jasmine test runner * * ```ts * import 'jasmine' * * beforeEach(() => engage(new Actors())) * ``` * * ### Using with Cucumber.js test runner * * ```ts * import { Before } from '@cucumber/cucumber' * * Before(() => engage(new Actors())) * ``` * * ## Learn more * - {@apilink Actor} * - {@apilink Cast} * - {@apilink engage} * * @param actors */ engage(actors: Cast): void; /** * Instantiates or retrieves an {@apilink Actor} * called `name` if one has already been instantiated. * * For your convenience, use {@apilink actorCalled} function instead. * * ## Usage with Mocha * * ```typescript * import { describe, it } from 'mocha'; * import { actorCalled } from '@serenity-js/core'; * * describe('Feature', () => { * * it('should have some behaviour', () => * actorCalled('James').attemptsTo( * // ... activities * )) * }) * ``` * * ## Usage with Jasmine * * ```typescript * import 'jasmine'; * import { actorCalled } from '@serenity-js/core'; * * describe('Feature', () => { * * it('should have some behaviour', () => * actorCalled('James').attemptsTo( * // ... activities * )) * }) * ``` * * ## Usage with Cucumber * * ```typescript * import { actorCalled } from '@serenity-js/core'; * import { Given } from '@cucumber/cucumber'; * * Given(/(.*?) is a registered user/, (name: string) => * actorCalled(name).attemptsTo( * // ... activities * )) * ``` * * ## Learn more * * - {@apilink engage} * - {@apilink Actor} * - {@apilink Cast} * - {@apilink actorCalled} * * @param name * The name of the actor to instantiate or retrieve */ theActorCalled(name: string): Actor; /** * Retrieves an actor who was last instantiated or retrieved * using {@apilink Serenity.theActorCalled}. * * This function is particularly useful when automating Cucumber scenarios. * * For your convenience, use {@apilink actorInTheSpotlight} function instead. * * ## Usage with Cucumber * * ```ts * import { actorCalled } from '@serenity-js/core'; * import { Given, When } from '@cucumber/cucumber'; * * Given(/(.*?) is a registered user/, (name: string) => * actorCalled(name).attemptsTo( * // ... activities * )) * * When(/(?:he|she|they) browse their recent orders/, () => * actorInTheSpotlight().attemptsTo( * // ... activities * )) * ``` * * ## Learn more * * - {@apilink engage} * - {@apilink actorCalled} * - {@apilink actorInTheSpotlight} * - {@apilink Actor} * - {@apilink Cast} */ theActorInTheSpotlight(): Actor; announce(...events: Array): void; currentTime(): Timestamp; assignNewSceneId(): CorrelationId; currentSceneId(): CorrelationId; assignNewActivityId(activityDetails: ActivityDetails): CorrelationId; createError(errorType: new (...args: any[]) => RE, options: ErrorOptions): RE; /** * @package */ waitForNextCue(): Promise; cwd(): Path; } //# sourceMappingURL=Serenity.d.ts.map