Usage in Deno
import * as mod from "node:assert";
The node:assert module provides a set of assertion functions for verifying
invariants.
Classes #
Indicates the failure of an assertion. All errors thrown by the node:assert module will be instances of the AssertionError class.
Functions #
Tests for deep equality between the actual and expected parameters.
"Deep" equality means that the enumerable "own" properties of child objects
are recursively evaluated also by the following rules.
Awaits the asyncFn promise or, if asyncFn is a function, immediately
calls the function and awaits the returned promise to complete. It will then
check that the promise is not rejected.
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.
Throws value if value is not undefined or null. This is useful when
testing the error argument in callbacks. The stack trace contains all frames
from the error passed to ifError() including the potential new frames for ifError() itself.
Tests strict inequality between the actual and expected parameters as
determined by Object.is().
assert.partialDeepStrictEqual() Asserts the equivalence between the actual and expected parameters through a
deep comparison, ensuring that all properties in the expected parameter are
present in the actual parameter with equivalent values, not allowing type coercion.
The main difference with assert.deepStrictEqual() is that assert.partialDeepStrictEqual() does not require
all properties in the actual parameter to be present in the expected parameter.
This method should always pass the same test cases as assert.deepStrictEqual(), behaving as a super set of it.
Awaits the asyncFn promise or, if asyncFn is a function, immediately
calls the function and awaits the returned promise to complete. It will then
check that the promise is rejected.
Tests strict equality between the actual and expected parameters as
determined by Object.is().
Interfaces #
Namespaces #
In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example, deepEqual will behave like deepStrictEqual.