Assertions
assert.deepStrictEqual()
Checks nested values with strict deep equality. Useful for verifying complete returned data structures without stringifying them; avoid comparing nondeterministic fields unless they are part of the contract. Tested on Node.js 22.16.0. Example output (one line per entry): ["ERR_ASSERTION"].
Formal Syntax & Structure
nodejs syntaxnodejs
assert.deepStrictEqual(actual, expected[, message])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| actual | any | Observed value. |
| expected | any | Required value. |
| message | string | Error | Failure detail. |
Return Value
undefined
Returns normally or throws.
Working Example
Example Snippetnodejs
import assert from 'node:assert/strict';assert.deepStrictEqual({ items: [2] }, { items: [2] });try { assert.deepStrictEqual({ n: 2 }, { n: '2' });}catch (e) { console.log(e.code);}