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 preset.

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 assert from "assert";
import assert from "node:assert";
import { 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 ❤️‍🔥 in Boston by Josh Goldberg and contributors.