Skip to main content

includes

Callable

  • includes(...answerableArguments: [expected: Answerable<string>]): Expectation<string>

  • Creates an expectation that is met when the actual string value includes a substring of expected.

    Ensuring that a given string includes the expected substring

    import { actorCalled } from '@serenity-js/core'
    import { Ensure, includes } from '@serenity-js/assertions'

    await actorCalled('Ester').attemptsTo(
    Ensure.that('Hello World!', includes('World')),
    )

    Ensuring that page URL includes the expected substring

    Page.current().url() returns a QuestionAdapter<URL>, a proxy object around the standard Node.js URL class, offering access to string properties such as hostname, pathname, and so on.

    import { actorCalled } from '@serenity-js/core'
    import { Ensure, includes } from '@serenity-js/assertions'
    import { Navigate, Page } from '@serenity-js/web'

    await actorCalled('Ester').attemptsTo(
    Navigate.to('https://serenity-js.org/handbook'),
    Ensure.that(Page.current().url().hostname, includes('serenity-js')),
    Ensure.that(Page.current().url().pathname, includes('book')),
    )

    Parameters

    • rest...answerableArguments: [expected: Answerable<string>]

    Returns Expectation<string>