Skip to content

Commit 3f78a51

Browse files
himself65targos
authored andcommitted
doc: add examples at assert.strictEqual
PR-URL: #28092 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent d611f5a commit 3f78a51

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/api/assert.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,14 @@ assert.strictEqual('Hello foobar', 'Hello World!');
10651065
// + 'Hello foobar'
10661066
// - 'Hello World!'
10671067
// ^
1068+
1069+
const apples = 1;
1070+
const oranges = 2;
1071+
assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
1072+
// AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
1073+
1074+
assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
1075+
// TypeError: Inputs are not identical
10681076
```
10691077

10701078
If the values are not strictly equal, an `AssertionError` is thrown with a

0 commit comments

Comments
 (0)