import {Stage} from '@serenity-js/core/lib/stage'
public class | source

Stage

The place where Actors perform.

In more technical terms, the Stage is the main event bus propagating DomainEvents to Actors it instantiates and StageCrewMembers that have been registered with it.

See also:

Constructor Summary

Public Constructor
public

constructor(cast: Cast, manager: StageManager)

Member Summary

Public Members
public

cast: *

Method Summary

Public Methods
public

actor(name: string): Actor

Instantiates a new Actor or fetches an existing one by their name if they've already been instantiated.

public

announce(event: DomainEvent): void

Notifies all the assigned listeners of the event.

public

assign(listeners: ListensToDomainEvents[]): void

Assigns listeners to be notified of DomainEvents emitted via Stage#announce

public

Generates and remembers a CorrelationId for the current Activity.

public

Generates and remembers a CorrelationId for the current scene.

public

Returns the CorrelationId for the current Activity.

public

Returns the CorrelationId for the current scene.

public

Returns current time.

public

engage(actors: Cast): void

Configures the Stage to prepare Actors instantiated via Stage#actor using the provided Cast.

public

theActorCalled(name: string): Actor

An alias for Stage#actor

public

Returns the last Actor instantiated via Stage#actor.

public

theShowHasStarted(): boolean

Returns {true} if there is an Actor in the spotlight, {false} otherwise.

public

waitForNextCue(): Promise<void>

Returns a Promise that will be resolved when any asynchronous post-processing activities performed by Serenity/JS are completed.

Public Constructors

public constructor(cast: Cast, manager: StageManager) source

Params:

NameTypeAttributeDescription
cast Cast
manager StageManager

Public Members

public cast: * source

Public Methods

public announce(event: DomainEvent): void source

Notifies all the assigned listeners of the event.

Params:

NameTypeAttributeDescription
event DomainEvent

Returns:

void

Listens:

DomainEvent

public assign(listeners: ListensToDomainEvents[]): void source

Assigns listeners to be notified of DomainEvents emitted via Stage#announce

Params:

NameTypeAttributeDescription
listeners ListensToDomainEvents[]

Returns:

void

public assignNewActivityId(): CorrelationId source

Generates and remembers a CorrelationId for the current Activity.

This method should be used in custom test runner adapters when instantiating an ActivityStarts event.

Returns:

CorrelationId

public assignNewSceneId(): CorrelationId source

Generates and remembers a CorrelationId for the current scene.

This method should be used in custom test runner adapters when instantiating a SceneStarts event.

Returns:

CorrelationId

public currentActivityId(): CorrelationId source

Returns the CorrelationId for the current Activity.

Returns:

CorrelationId

public currentSceneId(): CorrelationId source

Returns the CorrelationId for the current scene.

Returns:

CorrelationId

public currentTime(): Timestamp source

Returns current time. This method should be used whenever DomainEvent objects are instantiated by hand.

Returns:

Timestamp

public engage(actors: Cast): void source

Configures the Stage to prepare Actors instantiated via Stage#actor using the provided Cast.

Params:

NameTypeAttributeDescription
actors Cast

Returns:

void

public theActorCalled(name: string): Actor source

An alias for Stage#actor

Params:

NameTypeAttributeDescription
name string

Returns:

Actor

public theShowHasStarted(): boolean source

Returns {true} if there is an Actor in the spotlight, {false} otherwise.

Returns:

boolean

public waitForNextCue(): Promise<void> source

Returns a Promise that will be resolved when any asynchronous post-processing activities performed by Serenity/JS are completed.

Returns:

Promise<void>