Skip to main content

Action

The Action class is the container for small atomic low level actions to be wrapped for the Screenplay Pattern.

Methods

performAs

abstract performAs(actor: Actor): Promise<any>;
  • Description: Abstract method to override with custom implementation. This method holds the actual action execution code.
  • Parameters:
    • actor - The actor performing this action.
  • Returns: Promise<any> - Returns a promise based on the execution details.

orSkipOnFail

Introduced in: 0.5.0

public get orSkipOnFail(): this;
  • Description: Allows to skip an action on fail.
  • Returns: this - Returns the current action.

Usage:

// Would skip the step on error without breaking the execution
await actor.attemptsTo(
Do.something().orSkipOnFail,
);

getCanSkipOnFail

Introduced in: 0.5.0

public getCanSkipOnFail(): boolean;
  • Description: This functions is used in the internal flow. It is not meant to be used in test code.
  • Returns: boolean - Returns the orSkipOnFail state

Methods inherited from UsingAlias

withAbilityAlias

Introduced in: 0.3.0

public withAbilityAlias(alias: string): this;
  • Description: Defines the ability alias to be used during execution.
  • Parameters:
    • alias - The alias.
  • Returns: this - Returns the current action.

Usage:

await actor.attemptsTo(
Do.something().withAbilityAlias('myAlias'),
);

Methods inherited from UsingLogging

setCallStackInitializeCalledWith

This methods is used to announce the parameters the initial object instanciation is called with.

info

Ensure that you use this function for custom screenplay elements to ensure proper logging.

Introduced in core: 0.4.0

public setCallStackInitializeCalledWith(calledWith: CallStackCalledWith): void
  • Description: Sets the call stack to be used during initialization.
  • Parameters:
    • calledWith - The parameters for the initializing static function.
  • Returns: void - Does not return a value.

Usage:

Do.ts
// called like Do.something(myInput);
public static something(input: any): Do {
const instance = new Do(input);
instance.setCallStackInitializeCalledWith({ input });
return instance;
}

addToCallStack

This methods is used to announce callstack information for subsequent chaned functions to enhance the operation.

info

Ensure that you use this function for custom screenplay elements to ensure proper logging.

Introduced in core: 0.4.0

public addToCallStack(entry: CallStackInfo): void
  • Description: Adds CallStackInfo to the internal call stack
  • Parameters:
    • entry - The CallStackInfo to add.
  • Returns: void - Does not return a value.

Usage:

Do.ts
// called like Do.something().withData(data);
public withData(data: any): this {
this.data = data;
this.addToCallStack({ caller: 'withData', calledWith: { data } });
return this;
}

getCallStack

info

This functions is used in the internal flow. It is not meant to be used in custom code. Its purpose is to support the core's logging capabilities.

Introduced in core: 0.4.0

public addToCallStack(entry: CallStackInfo): void
  • Description: Gets the internal callstack.
  • Returns: CallStackInfo[] - The internal callstack state.