summaryrefslogtreecommitdiff
path: root/doc/api/assert.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r--doc/api/assert.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md
index 9a37d5f26c..7d07fbbf0c 100644
--- a/doc/api/assert.md
+++ b/doc/api/assert.md
@@ -18,6 +18,9 @@ For more information about the used equality comparisons see
added: REPLACEME
changes:
- version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/REPLACEME
+ description: Added error diffs to the strict mode
+ - version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/17002
description: Added strict mode to the assert module.
-->
@@ -26,12 +29,42 @@ When using the `strict mode`, any `assert` function will use the equality used i
the strict function mode. So [`assert.deepEqual()`][] will, for example, work the
same as [`assert.deepStrictEqual()`][].
+On top of that, error messages which involve objects produce an error diff
+instead of displaying both objects. That is not the case for the legacy mode.
+
It can be accessed using:
```js
const assert = require('assert').strict;
```
+Example error diff (the `expected`, `actual`, and `Lines skipped` will be on a
+single row):
+
+```js
+const assert = require('assert').strict;
+
+assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
+```
+
+```diff
+AssertionError [ERR_ASSERTION]: Input A expected to deepStrictEqual input B:
++ expected
+- actual
+... Lines skipped
+
+ [
+ [
+...
+ 2,
+- 3
++ '3'
+ ],
+...
+ 5
+ ]
+```
+
## Legacy mode
> Stability: 0 - Deprecated: Use strict mode instead.