Wraps assertion and throws an error with message if assertion fails.

const stringWithMessage = expect(
string,
(_, v) => `Expected string, got ${typeof v}`
);
  • Type Parameters

    • $Assertion extends UnknownAssertion

    Parameters

    • assertion: $Assertion

      Assertion to be checked.

    • message: ((error: any, value: unknown) => string)

      Message to be used in error.

        • (error, value): string
        • Parameters

          • error: any
          • value: unknown

          Returns string

    Returns $Assertion