Constructor Summary
Public Constructor | ||
public |
constructor(clock: Clock) |
Method Summary
Public Methods | ||
public |
announce(event: DomainEvent): void |
|
public |
|
|
public |
|
|
public |
configure(config: SerenityConfig): void Configures Serenity/JS. |
|
public |
|
|
public |
|
|
public |
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 |
theActorCalled(name: string): Actor Instantiates or retrieves an actor Actor
called |
|
public |
Retrieves an actor who was last instantiated or retrieved using actorCalled. |
Public Constructors
Public Methods
public announce(event: DomainEvent): void source
Params:
Name | Type | Attribute | Description |
event | DomainEvent |
Returns:
void |
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:
Name | Type | Attribute | Description |
config | SerenityConfig |
Returns:
void |
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:
Name | Type | Attribute | Description |
actors | Cast |
Returns:
void |
Examples:
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();
import 'jasmine';
beforeEach(() => engage(new Actors()));
import { Before } from 'cucumber';
Before(() => engage(new Actors());
public theActorCalled(name: string): Actor source
Instantiates or retrieves an actor Actor
called name
if one has already been instantiated.
Params:
Name | Type | Attribute | Description |
name | string | The name of the actor to instantiate or retrieve |
Examples:
import 'jasmine';
import { actorCalled } from '@serenity-js/core';
describe('Feature', () => {
it('should have some behaviour', () =>
actorCalled('James').attemptsTo(
// ... activities
));
});
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.
Examples:
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
));