fail

external fun fail(): Nothing(source)
external fun fail(message: String = definedExternally): Nothing(source)
external fun fail(message: JsError = definedExternally): Nothing(source)

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 'node: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.

Since

v0.1.21

Parameters

message='Failed'


external fun fail(actual: Any?, expected: Any?): Nothing(source)
external fun fail(actual: Any?, expected: Any?, message: String = definedExternally, operator: String = definedExternally, stackStartFn: Function<*> = definedExternally): Nothing(source)
external fun fail(actual: Any?, expected: Any?, message: JsError = definedExternally, operator: String = definedExternally, stackStartFn: Function<*> = definedExternally): Nothing(source)