Skip to content

Commit 3ad8799

Browse files
himself65Trott
authored andcommitted
doc: add examples at assert.strictEqual
PR-URL: #28092 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 7e977d7 commit 3ad8799

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)