Skip to content

assertStrict

Prefer strict assertion mode from Node.js for better error messages and behavior.

✅ This rule is included in the node logical presets.

In strict assertion mode, non-strict methods like deepEqual() behave like their strict counterparts (deepStrictEqual()). Strict mode provides better error messages with diffs and more reliable equality checks, reducing the risk of false positives in tests.

import
function assert(value: unknown, message?: string | Error): asserts value

An alias of

assert.ok

.

@sincev0.5.9

@paramvalue The input that is checked for being truthy.

assert
from "assert";
import
function assert(value: unknown, message?: string | Error): asserts value

An alias of

assert.ok

.

@sincev0.5.9

@paramvalue The input that is checked for being truthy.

assert
from "node:assert";
import {
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void

Strict assertion mode

An alias of

deepStrictEqual

.

Legacy assertion mode

Stability: 3 - Legacy: Use

deepStrictEqual

instead.

Tests for deep equality between the actual and expected parameters. Consider using

deepStrictEqual

instead.

deepEqual

can have surprising results.

Deep equality means that the enumerable "own" properties of child objects are also recursively evaluated by the following rules.

@sincev0.1.21

deepEqual
} from "node:assert";

This rule is not configurable.

If you specifically need the non-strict behavior of assertion methods (for example, when testing legacy code that relies on coercive equality), you might choose not to enable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.