Skip to main content

actorCalled

Callable

  • actorCalled(name: string): Actor

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

    This method is an alias for Serenity.theActorCalled.

    Usage with Cucumber

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

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

    Usage with Jasmine

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

    describe('Feature', () => {

    it('should have some behaviour', async () {
    await actorCalled('James').attemptsTo(
    // ... activities
    )
    })
    })

    Usage with Mocha

    import { describe, it } from 'mocha';
    import { actorCalled } from '@serenity-js/core';

    describe('Feature', () => {

    it('should have some behaviour', async () => {
    await actorCalled('James').attemptsTo(
    // ... activities
    )
    })
    })

    Usage with Playwright Test

    When using Serenity/JS with Playwright Test, you should use either the default actor fixture or the injected actorCalled function instead of importing it from @serenity-js/core.

    import { describe, it } from '@serenity-js/playwright-test';

    describe('Feature', () => {

    it('should have some behaviour', async ({ actorCalled }) => {
    await actorCalled('James').attemptsTo(
    // ... activities
    )
    })
    })

    Learn more


    Parameters

    • name: string

      The name of the actor to instantiate or retrieve

    Returns Actor