Skip to content

Commit d93cdf1

Browse files
committed
doc: add examples at assert.strictEqual
1 parent 5c61c5d commit d93cdf1

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
@@ -1074,6 +1074,14 @@ assert.strictEqual('Hello foobar', 'Hello World!');
10741074
// + 'Hello foobar'
10751075
// - 'Hello World!'
10761076
// ^
1077+
1078+
const apples = 1;
1079+
const oranges = 2;
1080+
assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
1081+
// AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
1082+
1083+
assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
1084+
// TypeError: Inputs are not identical
10771085
```
10781086

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

0 commit comments

Comments
 (0)