Task
The Task class is the container for a list of other Tasks and/or Actions. It is used to build sequences which are used at multiple places in the test code.
An example for it is a Login Task which is a sequence of fill Actions for form fields and pressing a button to trigger the login.
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 a task on fail.
- Returns:
this- Returns the current task.
Usage:
// Would skip the step on error without breaking the execution
await actor.attemptsTo(
Execute.task().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(
Execute.task().withAbilityAlias('myAlias'),
);
Methods inherited from UsingLogging
setCallStackInitializeCalledWith
This methods is used to announce the parameters the initial object instanciation is called with.
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:
// 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.
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:
// called like Do.something().withData(data);
public withData(data: any): this {
this.data = data;
this.addToCallStack({ caller: 'withData', calledWith: { data } });
return this;
}
getCallStack
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.