• Throws an AssertionError with the provided error message or a default error message. If the message parameter is an instance of an Error then it will be thrown instead of the AssertionError.

    import assert from 'assert/strict';

    assert.fail();
    // AssertionError [ERR_ASSERTION]: Failed

    assert.fail('boom');
    // AssertionError [ERR_ASSERTION]: boom

    assert.fail(new TypeError('need array'));
    // TypeError: need array

    Using assert.fail() with more than two arguments is possible but deprecated. See below for further details.

    Parameters

    • Optional message: string | Error

    Returns never

  • Deprecated

    since v10.0.0 - use fail([message]) or other assert functions instead.

    Parameters

    • actual: unknown
    • expected: unknown
    • Optional message: string | Error
    • Optional operator: string
    • Optional stackStartFn: Function

    Returns never

Generated using TypeDoc