import {Serenity} from '@serenity-js/core'
public class | source

Serenity

You can directly use an instance of this class. serenity

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

announce(event: DomainEvent): void

public

callToStageFor(actors: *): *

this method was deprecated.
public

configure(config: SerenityConfig): void

Configures Serenity/JS.

public
public

engage(actors: Cast): void

Re-configures Serenity/JS with a new Cast of Actors you'd like to use in any subsequent call to actorCalled.

This method provides an alternative to calling Actor#whoCan directly in your tests and you'd typically us it in a "before each" hook of your test runner of choice.

public

setTheStage(stageCrewMembers: *)

this method was deprecated.
this method is experimental.
public

theActorCalled(name: string): Actor

Instantiates or retrieves an actor Actor called name if one has already been instantiated.

public

Retrieves an actor who was last instantiated or retrieved using actorCalled.

Public Constructors

public constructor() source

Public Methods

public announce(event: DomainEvent): void source

Params:

NameTypeAttributeDescription
event DomainEvent

Returns:

void

public callToStageFor(actors: *): * source

this method was deprecated.

Params:

NameTypeAttributeDescription
actors *

Returns:

*

public configure(config: SerenityConfig): void source

Configures Serenity/JS. Every call to this function replaces the previous configuration provided, so this function should called be exactly once in your test suite.

Params:

NameTypeAttributeDescription
config SerenityConfig

Returns:

void

public currentTime(): Timestamp source

Returns:

Timestamp

public engage(actors: Cast): void source

Re-configures Serenity/JS with a new Cast of Actors you'd like to use in any subsequent call to actorCalled.

This method provides an alternative to calling Actor#whoCan directly in your tests and you'd typically us it in a "before each" hook of your test runner of choice.

Params:

NameTypeAttributeDescription
actors Cast

Returns:

void

Examples:

Engaging a cast of actors
 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();
Usage with Jasmine
 import 'jasmine';

 beforeEach(() => engage(new Actors()));
Usage with Cucumber
 import { Before } from 'cucumber';

 Before(() => engage(new Actors());

public setTheStage(stageCrewMembers: *) source

this method was deprecated.
this method is experimental.

Params:

NameTypeAttributeDescription
stageCrewMembers *

public theActorCalled(name: string): Actor source

Instantiates or retrieves an actor Actor called name if one has already been instantiated.

Params:

NameTypeAttributeDescription
name string

The name of the actor to instantiate or retrieve

Returns:

Actor

Examples:

Usage with Jasmine
  import 'jasmine';
  import { actorCalled } from '@serenity-js/core';

  describe('Feature', () => {

     it('should have some behaviour', () =>
         actorCalled('James').attemptsTo(
             // ... activities
         ));
  });
Usage with Cucumber
  import { actorCalled } from '@serenity-js/core';
  import { Given } from 'cucumber';

  Given(/(.*?) is a registered user/, (name: string) =>
     actorCalled(name).attemptsTo(
             // ... activities
         ));

public theActorInTheSpotlight(): Actor source

Retrieves an actor who was last instantiated or retrieved using actorCalled.

This function is particularly useful when automating Cucumber scenarios.

Returns:

Actor

Examples:

<captiongit>Usage with Cucumber</caption>
  import { actorCalled } from '@serenity-js/core';
  import { Given, When } from 'cucumber';

  Given(/(.*?) is a registered user/, (name: string) =>
     actorCalled(name).attemptsTo(
             // ... activities
         ));

  When(/(?:he|she|they) browse their recent orders/, () =>
     actorInTheSpotlight().attemptsTo(
             // ... activities
         ));