Skip to main content

externalisGreaterThan

Callable


  • Creates an expectation that is met when the actual value of type number is greater than the expected number.

    Ensuring that a given number is greater than the expected number

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

    await actorCalled('Ester').attemptsTo(
    Ensure.that(10, isGreaterThan(5)),
    )

    Ensuring that a given number is within the expected range

    import { actorCalled, Expectation, d } from '@serenity-js/core'
    import { Ensure, and, equals, isGreaterThan, isLessThan, or } from '@serenity-js/assertions'

    const isWithinRange = (lowerBound: Answerable<number>, upperBound: Answerable<number>) =>
    Expectation.to(d`have value that is between ${ lowerBound } and ${ upperBound }`)
    .soThatActual(
    and(
    or(equals(lowerBound), isGreaterThan(lowerBound)),
    or(equals(upperBound), isLessThan(upperBound)),
    )
    ),

    await actorCalled('Ester').attemptsTo(
    Ensure.that(
    7,
    isWithinRange(5, 10)
    ),
    )

    Parameters

    • externalrest...answerableArguments: [expected: Answerable<number>]

    Returns Expectation<number>