Skip to main content

Check <Actual>

A flow control statement that enables an Actor to decide between two alternate series of activities.

Think of it as a Screenplay Pattern equivalent of the traditional if statement.

Choose between two alternative sequences of activities

import { equals } from '@serenity-js/assertions'
import { actorCalled, Check } from '@serenity-js/core'

await actorCalled('Chuck').attemptsTo(
Check.whether(process.env.MODE, equals('prod'))
.andIfSo(
LogInAsProdUser(),
)
.otherwise(
LogInAsTestUser(),
)
)

Perform a sequence of activities when a condition is met

import { actorCalled, Check } from '@serenity-js/core'
import { isVisible } from '@serenity-js/web'

await actorCalled('Chuck').attemptsTo(
Check.whether(CookieConsentBanner(), isVisible())
.andIfSo(
AcceptNecessaryCookies(),
)
)

Hierarchy

Index

Methods

staticwhether

instantiationLocation

  • instantiationLocation(): FileSystemLocation
  • Returns the location where this Activity was instantiated.


    Returns FileSystemLocation

toString

  • toString(): string
  • Generates a human-friendly description to be used when reporting this Activity.

    Note: When this activity is reported, token #actor in the description will be replaced with the name of the actor performing this Activity.

    For example, #actor clicks on a button becomes Wendy clicks on a button.


    Returns string

otherwise

performAs