Functions

Static Public Summary
public

actorCalled(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

configure(config: SerenityConfig): void

Configures Serenity/JS.

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 function 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

formatted(templates: TemplateStringsArray, placeholders: Array<Answerable<any>>): string

A tag function returning a human-readable description of a template containing one or more Answerables.

public

inspected(value: Answerable<any>): string

Provides a human-readable description of the {@link Answerable<T>}.

public

trimmed(templates: TemplateStringsArray, placeholders: Array<string>): string

A tag function trimming the leading and trailing whitespace from multi-line strings.

Static Public

public actorCalled(name: string): Actor source

import {actorCalled} from '@serenity-js/core'

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

This method is an alias for Serenity#theActorCalled.

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 actorInTheSpotlight(): Actor source

import {actorInTheSpotlight} from '@serenity-js/core'

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

This function is particularly useful when automating Cucumber scenarios.

This function is an alias for Serenity#theActorInTheSpotlight.

Returns:

Actor

Examples:

Usage with Cucumber
  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
         ));

public configure(config: SerenityConfig): void source

import {configure} from '@serenity-js/core'

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.

This function is an alias for Serenity#configure.

Params:

NameTypeAttributeDescription
config SerenityConfig

Returns:

void

public engage(actors: Cast): void source

import {engage} from '@serenity-js/core'

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

This function 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.

This function is an alias for Serenity#engage.

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 formatted(templates: TemplateStringsArray, placeholders: Array<Answerable<any>>): string source

import {formatted} from '@serenity-js/core/lib/io'

A tag function returning a human-readable description of a template containing one or more Answerables.

Params:

NameTypeAttributeDescription
templates TemplateStringsArray
placeholders Array<Answerable<any>>

Returns:

string

public inspected(value: Answerable<any>): string source

import {inspected} from '@serenity-js/core/lib/io'

Provides a human-readable description of the {@link Answerable<T>}. Similar to util~inspect.

Params:

NameTypeAttributeDescription
value Answerable<any>

Returns:

string

public trimmed(templates: TemplateStringsArray, placeholders: Array<string>): string source

import {trimmed} from '@serenity-js/core/lib/io'

A tag function trimming the leading and trailing whitespace from multi-line strings.

Params:

NameTypeAttributeDescription
templates TemplateStringsArray
placeholders Array<string>

Returns:

string