Skip to main content

Stage

Stage is 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.

It is unlikely that you’ll ever need to interact with the Stage directly in your tests. Instead, you’ll use functions like actorCalled and actorInTheSpotlight.

Learn more

Implements

Index

Constructors

constructor

Methods

theActorCalled

  • theActorCalled(name: string): Actor

actor

  • actor(name: string): Actor
  • Instantiates a new Actor or fetches an existing one identified by their name if they’ve already been instantiated.


    Parameters

    • name: string

      Case-sensitive name of the Actor, e.g. Alice

    Returns Actor

theActorInTheSpotlight

  • theActorInTheSpotlight(): Actor
  • Returns the last Actor instantiated via Stage.actor. Useful when you don’t can’t or choose not to reference the actor by their name.

    @throws

    If no Actor has been activated yet


    Returns Actor

theShowHasStarted

  • theShowHasStarted(): boolean
  • Returns true if there is an Actor in the spotlight, false otherwise.


    Returns boolean

engage

  • engage(actors: Cast): void
  • Configures the Stage to prepare Actors instantiated via Stage.actor using the provided Cast.


    Parameters

    Returns void

assign

announce

  • Notifies all the assigned listeners of the events, emitting them one by one.


    Parameters

    Returns void

currentTime

  • Returns current time. This method should be used whenever DomainEvent objects are instantiated by you programmatically.


    Returns Timestamp

assignNewSceneId

  • assignNewSceneId(): CorrelationId
  • Generates and remembers a CorrelationId for the current scene.

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

    Learn more


    Returns CorrelationId

currentSceneId

  • currentSceneId(): CorrelationId
  • Returns the CorrelationId for the current scene.

    Learn more


    Returns CorrelationId

assignNewActivityId

  • assignNewActivityId(activityDetails: ActivityDetails): CorrelationId
  • Generates and remembers a CorrelationId for the current Activity.

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

    Learn more


    Parameters

    • activityDetails: ActivityDetails

    Returns CorrelationId

currentActivityId

  • currentActivityId(): CorrelationId

waitForNextCue

  • waitForNextCue(): Promise<void>
  • Returns a Promise that will be resolved when any asynchronous post-processing activities performed by Serenity/JS are completed.

    Invoked in Serenity/JS test runner adapters to inform the test runner when the scenario has finished and when it’s safe for the test runner to proceed with the next test, or finish execution.


    Returns Promise<void>

createError

  • createError<RE>(errorType: new (...args: any[]) => RE, options: ErrorOptions): RE