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

Cast

Describes the Actors available to take part in the performance.

Examples:

Define a cast of actors interacting with a Web UI

 import { engage, Actor, Cast } from '@serenity-js/core';
 import { BrowseTheWeb } from '@serenity-js/protractor';
 import { protractor } from 'protractor';

 class UIActors implements Cast {
     prepare(actor: Actor) {
         return actor.whoCan(BrowseTheWeb.using(protractor.browser));
     }
 }

 beforeEach(() => engage(new UIActors()));
Using a generic cast

 import { engage, Cast } from '@serenity-js/core';
 import { BrowseTheWeb } from '@serenity-js/protractor';
 import { protractor } from 'protractor';

 beforeEach(() => engage(BrowseTheWeb.using(protractor.browser)));
Preparing actors differently based on their name

 import { actorCalled, engage, Cast } from '@serenity-js/core';
 import { BrowseTheWeb } from '@serenity-js/protractor';
 import { CallAnApi } from '@serenity-js/rest';
 import { protractor } from 'protractor';

 class Actors implements Cast {
     prepare(actor: Actor) {
         switch (actor.name) {
             case 'James':
                 return actor.whoCan(BrowseTheWeb.using(protractor.browser));
             default:
                 return actor.whoCan(CallAnApi.at(protractor.browser.baseUrl));
         }
     }
 }

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

 actorCalled('James') // returns an actor using a browser
 actorCalled('Alice') // returns an actor interacting with an API

See also:

Static Method Summary

Static Public Methods
public static

whereEveryoneCan(abilities: Ability[]): Cast

Creates a generic Cast implementation, where every actor is given all the abilities specified when the method is called.

Static Public Methods

public static whereEveryoneCan(abilities: Ability[]): Cast source

Creates a generic Cast implementation, where every actor is given all the abilities specified when the method is called.

Params:

NameTypeAttributeDescription
abilities Ability[]

Returns:

Cast