import {Check} from '@serenity-js/core/lib/screenplay/questions'
public class | source

Check

A control flow statement that enables the @serenity-js/core/lib/screenplay/actor~Actor either to choose whether or not to perform a series of activities, or to choose which of the two provided series of activities to perform.

Extends:

Task → Check

Indirect Implements:

Examples:

Choose from two alternatives
 import { equals } from '@serenity-js/assertions';
 import { Check } from '@serenity-js/core';

 actor.attemptsTo(
     Check.whether(process.env.MODE, equals('prod'))
         .andIfSo(
             LogInAsProdUser(),
         )
         .otherwise(
             LogInAsTestUser(),
         )
 );
Choose whether or not to perform an activity
 import { equals } from '@serenity-js/assertions';
 import { Check } from '@serenity-js/core';
 import { isDisplayed } from '@serenity-js/protractor';

 actor.attemptsTo(
     Check.whether(NewsletterModal(), isDisplayed())
         .andIfSo(
             DismissModal(),
         )
 );

Tests:

Static Method Summary

Static Public Methods
public static

whether(actual: Answerable, expectation: Expectation): {"andIfSo": *}

Constructor Summary

Public Constructor
public

constructor(actual: *, expectation: *, activities: *, alternativeActivities: *)

Method Summary

Public Methods
public

otherwise(alternativeActivities: Activity[]): Task

public

performAs(actor: AnswersQuestions & PerformsActivities): Promise<void>

Makes the provided @serenity-js/core/lib/screenplay/actor~Actor perform this @serenity-js/core/lib/screenplay~Task.

public

toString(): string

Generates a description to be used when reporting this @serenity-js/core/lib/screenplay~Activity.

Inherited Summary

From class Task
public static

where(description: string, activities: Activity[]): Task

A factory method to make defining the Tasks more convenient.

Static Public Methods

public static whether(actual: Answerable, expectation: Expectation): {"andIfSo": *} source

Params:

NameTypeAttributeDescription
actual Answerable
expectation Expectation

Returns:

{"andIfSo": *}

Public Constructors

public constructor(actual: *, expectation: *, activities: *, alternativeActivities: *) source

Params:

NameTypeAttributeDescription
actual *
expectation *
activities *
alternativeActivities *

Public Methods

public performAs(actor: AnswersQuestions & PerformsActivities): Promise<void> source

Makes the provided @serenity-js/core/lib/screenplay/actor~Actor perform this @serenity-js/core/lib/screenplay~Task.

Params:

NameTypeAttributeDescription
actor AnswersQuestions & PerformsActivities

Returns:

Promise<void>

See:

  • @serenity-js/core/lib/screenplay/actor~Actor
  • @serenity-js/core/lib/screenplay/actor~AnswersQuestions
  • @serenity-js/core/lib/screenplay/actor~PerformsActivities

public toString(): string source

Generates a description to be used when reporting this @serenity-js/core/lib/screenplay~Activity.

Returns:

string