Creates a scenario whose subject is expected 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 matcher must succeed.

  • ❌ in the subtest where the matcher is negated by .not, the message passed to withErrorWhenNegated relates to the error that is expected from the matcher.

scenario("when the subject is a number")
.subject(42)
.passes(e => e.toBe(42))
.withErrorWhenNegated("expected 42 not to be 42"); //Error when the matcher is preceded by `.not`

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

interface PassMatcherClause {
    withErrorWhenNegated(message: string): void;
}

Methods

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

    Parameters

    • message: string

      The error message expected from the matcher.

    Returns void