• Use for this testing pattern:

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

    Just do this

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

    Parameters

    • f: Promise<unknown>

      The async function that is expected to throw.

    • Optional message: string

    Returns Promise<never>