• Use for this testing pattern:

     try {
    call()
    assert.fail("this should never happen");
    } catch (e) {
    ...
    }

    Just do this

    try {
    shouldThrowSync(call); // If this succeeds unexpectedResultError is thrown.
    } catch(e) {
    ...
    }

    Parameters

    • f: (() => unknown)

      The function that is expected to throw.

        • (): unknown
        • Returns unknown

    • Optional message: string

    Returns never