Creates a scenario whose subject is expected ❌not to satisfy the matcher under test.

Consequently, in the describe() test block generated for this scenario:

  • ❌ in the subtest where the matcher is asserted, the message passed to withError relates to the error that is expected from the matcher.

  • ✅ in the subtest where the matcher is negated by .not, the matcher must succeed.

scenario("when the subject is a number")
.subject(7)
.fails(e => e.toBe(90))
.withError("expected 7 to be 90"); //Error when the matcher is not preceded by `.not`

You must never use .not when calling the matcher in this scenario: use ✅passes() instead.

interface FailMatcherClause {
    withError(message: string): void;
}

Methods

Methods

  • Describes the expected error message when the matcher is asserted.

    Parameters

    • message: string

      The error message expected from the matcher.

    Returns void