Skip to main content



  • isPresent<Actual>(): Expectation<Actual>

  • Creates an expectation that is met when the actual value is not undefined or null.

    Also, when the actual implements Optional, the expectation is met when calling Optional.isPresent() returns an Answerable that resolves to true

    Ensuring that a value is defined

    import { actorCalled } from '@serenity-js/core'
    import { CallAnApi, Send, GetRequest, LastResponse } from '@serenity-js/rest'
    import { Ensure, isPresent } from '@serenity-js/assertions'

    interface Product {
    name: string;

    interface ProductsResponse {
    products: Product[];

    await actorCalled('Apisitt')
    Ensure.that(LastResponse.body<ProductsResponse>().products[0], isPresent()),

    Checking if a PageElement is present

    import { actorCalled, Check } from '@serenity-js/core';
    import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright';
    import { By, Click, Navigate, PageElement } from '@serenity-js/web';
    import { Browser, chromium } from 'playwright';

    class NewsletterSubscription {
    static modal = () =>
    .describedAs('newsletter subscription modal')

    static closeButton = () =>
    .describedAs('close button')

    const browser = await chromium.launch({ headless: true });

    await actorCalled('Isabela')
    Check.whether(NewsletterSubscription.modal(), isPresent())

    Type parameters

    • Actual

    Returns Expectation<Actual>