Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
cd83df3
n-api: initialize a module via a special symbol
Apr 21, 2018
a4dae6c
src: prefer false instead of bool zero
danbev Apr 23, 2018
bd2e521
src: rename return var in VerifySpkac functions
danbev Apr 23, 2018
9eacd66
lib: make sure `console` is writable
kfarnung Apr 21, 2018
b5584c4
tools: modernize and optimize doc/addon-verify.js
vsemozhetbyt Apr 21, 2018
c5b3459
build: use -9 with `kill` in Makefile
Trott Apr 21, 2018
3bc5353
doc: fix spelling of API name in 10.0.0 changelog
tniessen Apr 24, 2018
26525ef
doc: fix typos in doc/changelogs/CHANGELOG_V10.md
vsemozhetbyt Apr 24, 2018
99e0b91
test: add checkMethods function for Certificate
danbev Apr 23, 2018
6bf816f
src: limit foreground tasks draining loop
ulan Apr 12, 2018
171cbb1
doc: fix net.Socket link inconsistencies
Hackzzila Apr 25, 2018
3bf736e
doc: update pull request template in guide
Hackzzila Apr 25, 2018
d4b19cf
test,n-api: re-write test_error in C
Apr 24, 2018
b239591
n-api,test: make methods static
Apr 24, 2018
b5bc6bd
src: fix Systemtap node_gc_stop probe
wcohen Apr 19, 2018
c9b202f
doc: add emitter.off() to events.md
Ajido Apr 25, 2018
7f6172b
doc: improve docs for Http2Session:frameError
ryzokuken Apr 23, 2018
391d2f8
crypto: simplify diffiehellman getFormat function
danbev Apr 24, 2018
e81bb9f
crypto: add getIntOption function to reduce dupl
danbev Apr 24, 2018
61e9396
crypto: add checkIsArrayBufferView
danbev Apr 24, 2018
e17280e
crypto: make pbkdf2 use checkIsArrayBufferView
danbev Apr 25, 2018
769b6c8
test: fix flaky child-process-exec-kill-throws
santigimeno Apr 22, 2018
2de3343
n-api,test: make method static
Apr 25, 2018
8d24b6e
n-api: update cli documentation
Apr 25, 2018
b5c1c14
n-api,test: remove superfluous persistent
Apr 25, 2018
375994f
inspector: Use default uv_listen backlog size
Apr 24, 2018
1385ffc
http: added aborted property to request
ronag Apr 17, 2018
61a56fe
test: added coverage for fs/promises API
mithunsasidharan Apr 23, 2018
b646566
test: removed assert.strictEqual message
kailashyogeshwar85 Apr 23, 2018
81de533
src: create per-isolate strings after platform setup
ulan Apr 20, 2018
c139d2a
doc: fix unhandled to uncaught
BridgeAR Apr 25, 2018
3a3144c
doc: remove os.uptime() Windows note
cjihrig Apr 25, 2018
44fdd36
src: remove SecureContext `_external` getter
addaleax Apr 23, 2018
705d9ec
n-api: remove unused Test function
danbev Apr 26, 2018
14188b1
doc: add Slack community to support options
hackygolucky Jan 16, 2018
1490164
inspector: allow concurrent inspector sessions
Apr 24, 2018
ab13f13
tools: show stdout/stderr for timed out tests
Trott Apr 24, 2018
cc09d7e
doc: remove console.table() as inspector-dependent
Trott Apr 26, 2018
73cd279
tls: specify options.name in validateKeyCert
danbev Apr 25, 2018
d9bc921
doc: fix typo in console.md
dhritzkiv Apr 27, 2018
701f536
doc: remove superfluous URL require statement
MarkTiedemann Apr 27, 2018
2ce4b7c
build: do not depend on `cp` in `PATH`
addaleax Apr 25, 2018
e0d2bc5
src: improve fatal exception
BridgeAR Apr 25, 2018
f0b2b26
http: refactor outgoing headers processing
apapirovski Apr 24, 2018
b47044a
doc: improve parameters for Http2Session:goaway event
ryzokuken Apr 26, 2018
8ddbac2
tools: add log output to crashes
BridgeAR Apr 25, 2018
a12d13a
tools: simplify HTML generation
vsemozhetbyt Apr 25, 2018
9c11a18
doc: remove eu-strip from tarball
jvelezpo Apr 25, 2018
ccf1b24
tools: remove redundant RegExp flag
vsemozhetbyt Apr 25, 2018
be34388
doc: unify and dedupe returned values in timers.md
vsemozhetbyt Apr 25, 2018
29bc735
console: fix console.table() display edge case
Trott Apr 26, 2018
3962c73
util: fix isInsideNodeModules inside error
apapirovski Apr 24, 2018
31812ed
src: remove unnecessary copy operations in tracing
addaleax Apr 27, 2018
b0e6f10
benchmark: add bench for zlib gzip + gunzip cycle
addaleax Apr 14, 2018
fd912a3
stream: only check options once in Duplex ctor
danbev Apr 27, 2018
e45e5b8
fs: point isFd to isUint32
danbev Apr 26, 2018
9b30bc4
tls: fix getEphemeralKeyInfo to support X25519
shigeki Apr 25, 2018
46bd862
http2: fix responses to long payload reqs
apapirovski Apr 16, 2018
9cf3ae5
doc: add missing backticks in n-api.md
vsemozhetbyt Apr 28, 2018
57e5a3e
doc: remove redundant empty lines
vsemozhetbyt Apr 29, 2018
ec2037d
child_process: fix leak when passing http sockets
santigimeno Apr 19, 2018
f5054d3
assert: minor error message improvements
BridgeAR Apr 26, 2018
7293c58
assert: make skipping indicator blue
BridgeAR Apr 26, 2018
90026c3
doc: improve assert docs
BridgeAR Apr 26, 2018
5542a98
doc: improve process event headers
BridgeAR Apr 26, 2018
7d9f1f3
http2: fix ping callback
BridgeAR Apr 26, 2018
645a97a
test: verify arguments length in common.expectsError
BridgeAR Apr 26, 2018
2b8b40f
test: fix a TODO and remove obsolete TODOs
BridgeAR Apr 26, 2018
348d391
build: remove --xcode configure switch
bnoordhuis Apr 26, 2018
05b7b8d
stream: fix error handling with async iteration
julien-f Apr 26, 2018
de9d1f1
doc: remove parenthetical in onboarding-extras
Trott Apr 29, 2018
58be6ef
src: avoid `std::make_unique`
addaleax Apr 28, 2018
b89d817
errors: minor (SystemError) refactoring
BridgeAR Apr 26, 2018
dfcf20f
crypto: use new OpenSSL constants in CipherBase
tniessen Apr 26, 2018
b61ae7f
doc: remove "has been known" tentativeness
Trott Apr 30, 2018
d7557e1
doc: refine napi_get_property_names() doc
Apr 29, 2018
7ac491b
n-api: document that native strings are copied
Apr 28, 2018
1908668
n-api: document the look of napi_external values
Apr 28, 2018
4bc87c1
doc: add parameters for settings events
ryzokuken Apr 27, 2018
f36a5e3
doc: remove redundant table of contents for N-API
AyushG3112 Apr 29, 2018
459c20c
doc: edit fs.createReadStream() highWaterMark
Trott May 1, 2018
5a839b9
doc: remove unclear text from fs.write()
Trott May 1, 2018
fcc5492
doc: clarify FileHandle text
Trott May 1, 2018
b0c0352
tools: dedupe property access in doc/type-parser
vsemozhetbyt Apr 28, 2018
54e9331
doc: specify types of listener parameter
vsemozhetbyt Apr 29, 2018
261776d
doc: mitigate `marked` bug
vsemozhetbyt Apr 29, 2018
abf1155
doc: add missing periods or colons
vsemozhetbyt Apr 29, 2018
b2bbc36
http2: remove unused using declarations node_http2
danbev Apr 30, 2018
e397d19
http2: remove unnecessary v8 qualified names
danbev Apr 30, 2018
42bbaa3
http2: reduce require calls in http2/core
danbev Apr 30, 2018
da8bc6a
deps: cherry-pick 76cab5f from upstream V8
targos Apr 27, 2018
ad793ab
n-api: test and doc napi_throw() of a primitive
Apr 29, 2018
56c27c6
doc: add more missing backticks
vsemozhetbyt Apr 29, 2018
166df9e
doc: remove squash guideline from onboarding doc
Trott Apr 30, 2018
7a769eb
doc: add squash guideline to pull-requests doc
Trott Apr 30, 2018
289e4ce
benchmark: fix next-tick-depth
apapirovski May 2, 2018
658fbdc
doc: add http.ClientRequest maxHeadersCount
darai0512 Apr 23, 2018
3912551
tools: fix TypeError from `test.py --time`
richardlau Apr 27, 2018
b0ed31c
doc: update writing-and-running-benchmarks.md
xsbchen Apr 28, 2018
e552158
timers: named anonymous functions
js-kyle Apr 29, 2018
b5931e1
child_process: name anonymous functions
SerayaEryn Apr 29, 2018
b24ee07
test: remove unnecessary strictEqual() argument from remoteClose()
dayloryanes Apr 26, 2018
4dce39a
test: use fs.copyFileSync()
richardlau Apr 26, 2018
74685f1
doc: add missing periods in documentation.md
vsemozhetbyt May 2, 2018
58a65d6
events: optimize condition for optimal scenario
apapirovski May 1, 2018
e854c95
util: improve spliceOne perf
apapirovski May 1, 2018
8b17e7a
doc: update cli flag in crypto.md
shobhitchittora Apr 29, 2018
391c420
doc: synchronize argument names for appendFile()
Trott May 3, 2018
1b9c40c
util: named anonymous functions
ccoxwell Apr 29, 2018
b6de6a7
lib: named anonymous functions
ccoxwell Apr 30, 2018
e553747
doc: update Collaborator Guide reference
Trott May 2, 2018
b2d6eb7
doc: cleanup n-api.md doc
mhdawson Apr 30, 2018
c0f1535
src: remove `kFlagNoShutdown` flag
addaleax Apr 28, 2018
c21a52f
src: access `ContextifyContext*` more directly in property cbs
addaleax May 1, 2018
f5d4253
src: refactor `BaseObject` internal field management
addaleax May 1, 2018
d7db306
doc: update examples for fs.access()
BeniCheni May 1, 2018
17dbf6c
n-api: make test_error functions static
Apr 27, 2018
3cf53b6
deps: patch V8 to 6.6.346.27
MylesBorins May 2, 2018
b2e8b9c
doc: fix mkdtemp() documentation
Trott May 4, 2018
745e0a5
doc: document using `domain` in REPL
AyushG3112 Apr 28, 2018
80bdff0
test: add fs/promises filehandle stat test
May 3, 2018
d3a219c
repl: add spaces to load/save messages
cjihrig May 5, 2018
6052ccc
test: rename misnamed test
Trott May 5, 2018
70b2e16
test: fix up N-API error test
May 3, 2018
54f3065
src: fix inconsistency in extern declaration
hashseed Apr 30, 2018
167de1f
build: check for different deprecation signatures
BridgeAR Apr 28, 2018
79e1260
doc: fix manpage warning
kapouer Apr 28, 2018
0b16c24
https: defines maxHeadersCount in the constructor
darai0512 Apr 22, 2018
df2cddc
src: removed unnecessary prototypes from Environment::SetProtoMethod
brandontruggles Apr 26, 2018
1de67c7
test: fix common.canCreateSymLink() on non-Windows
May 4, 2018
7b8e9ca
lib: expose FixedQueue internally and fix nextTick bug
apapirovski May 2, 2018
1ebec18
tls: cleanup onhandshakestart callback
apapirovski May 2, 2018
16970ff
benchmark: track exec time in next-tick-exec
apapirovski May 2, 2018
880772a
doc: fix N-API property descriptor documentation
Apr 30, 2018
8bd45d8
doc: updates crypto doc with openssl list -cipher-algorithms
shobhitchittora May 3, 2018
1109104
tls: remove sharedCreds in Server constructor
danbev May 3, 2018
e25f2c9
errors: remove dead code
BridgeAR May 2, 2018
6acefc3
http2: rename http2_state class to Http2State
danbev Apr 30, 2018
018b5ad
doc: add snake_case section for C-like structs
danbev May 2, 2018
d357875
src: add public API to expose the main V8 Platform
helloshuangzi May 1, 2018
bea4ffc
doc: update one more command in crypto.md
shobhitchittora May 3, 2018
4c4be85
Revert "stream: prevent 'end' to be emitted after 'error'"
mscdex May 1, 2018
ff619d3
url: fix WHATWG host formatting error
peakji May 3, 2018
a4d2089
tools: remove redundant code in doc/html.js
vsemozhetbyt May 4, 2018
98ccaea
doc: clearer doc-only deprecations
BridgeAR Apr 28, 2018
601f138
test: fix buffer writes on mips
BridgeAR Apr 27, 2018
578e054
test: fix test-cli-node-options.js on mips
BridgeAR Apr 28, 2018
0e88051
doc: add parameters for Http2Session:stream event
ryzokuken May 5, 2018
67e44bf
doc: edit text for DEP0104
Trott May 4, 2018
adf5b80
doc: edit text for DEP0101
Trott May 4, 2018
c6e4ffa
doc: edit text for DEP0012
Trott May 4, 2018
74c74db
doc: edit text for DEP0094
Trott May 4, 2018
f796b08
doc: fix text for DEP0085
Trott May 4, 2018
faa8193
doc: edit text for DEP0082
Trott May 4, 2018
73f5ea9
doc: fix minor typographical error in DEP0079 text
Trott May 4, 2018
b2b4871
doc: minor edit to DEP0065
Trott May 4, 2018
eed3f10
doc: edit text for DEP0013
Trott May 4, 2018
01560b6
doc: edit text about revoking deprecations
Trott May 4, 2018
70586c0
doc: excise "periodically" before "emit events"
jeswcollins May 7, 2018
8148fca
doc: update "Who to cc..." in COLLABORATOR_GUIDE
vsemozhetbyt May 6, 2018
0b5dd10
fs: move fs/promises to fs.promises
cjihrig May 3, 2018
ec65fe4
doc: add trace category for fs sync methods
chinhuang007 May 4, 2018
a7758c7
console: make console.table() use colored inspect
makenowjust May 4, 2018
bd27a59
doc: move tunniclm to Emeritus
Trott May 5, 2018
eb724f0
fs: remove broken code in promises/write
ChALkeR Apr 29, 2018
eb483db
fs: fchmod->fchown in promises/lchown
ChALkeR Apr 29, 2018
e995ae5
doc: clarify `this` in event listeners
dagolinuxoid May 5, 2018
2a1efa2
tools: add v10 to alternative version docs menu
vsemozhetbyt May 7, 2018
b2d3db4
test: use common.canCreateSymLink() consistently
cjihrig May 5, 2018
f7267b4
tools: add eslint check for skipIfEslintMissing
richardlau Apr 27, 2018
05ce635
doc: match console.count()/countReset() signatures
Lambdac0re May 8, 2018
e19200a
test: fix flaky http2-flow-control test
apapirovski May 6, 2018
687867d
2018-05-08, Version 10.1.0 (Current)
MylesBorins May 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: improve assert docs
This improves the error example output by reflecting the current
state. It also makes sure the examples are up to date in general.
`assert.throws` clarified the `ERR_AMBIGUOUS_ARGUMENT` error.

PR-URL: #20313
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed May 4, 2018
commit 90026c3f3edcb9e930e3f37a0dc41dfb88942a0b
209 changes: 128 additions & 81 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,25 @@ It can be accessed using:
const assert = require('assert').strict;
```

Example error diff (the `expected`, `actual`, and `Lines skipped` will be on a
single row):
Example error diff:

```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
]
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual ... Lines skipped
//
// [
// [
// ...
// 2,
// - 3
// + '3'
// ],
// ...
// 5
// ]
```

To deactivate the colors, use the `NODE_DISABLE_COLORS` environment variable.
Expand Down Expand Up @@ -319,43 +313,67 @@ are recursively evaluated also by the following rules.
```js
const assert = require('assert').strict;

// This fails because 1 !== '1'.
assert.deepStrictEqual({ a: 1 }, { a: '1' });
// AssertionError: { a: 1 } deepStrictEqual { a: '1' }
// because 1 !== '1' using SameValue comparison
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// {
// - a: 1
// + a: '1'
// }

// The following objects don't have own properties
const date = new Date();
const object = {};
const fakeDate = {};
Object.setPrototypeOf(fakeDate, Date.prototype);

// Different [[Prototype]]:
assert.deepStrictEqual(object, fakeDate);
// AssertionError: {} deepStrictEqual Date {}
// Different [[Prototype]]
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// - {}
// + Date {}

// Different type tags:
assert.deepStrictEqual(date, fakeDate);
// AssertionError: 2017-03-11T14:25:31.849Z deepStrictEqual Date {}
// Different type tags
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// - 2018-04-26T00:49:08.604Z
// + Date {}

assert.deepStrictEqual(NaN, NaN);
// OK, because of the SameValue comparison

// Different unwrapped numbers:
assert.deepStrictEqual(new Number(1), new Number(2));
// Fails because the wrapped number is unwrapped and compared as well.
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// - [Number: 1]
// + [Number: 2]

assert.deepStrictEqual(new String('foo'), Object('foo'));
// OK because the object and the string are identical when unwrapped.

assert.deepStrictEqual(-0, -0);
// OK

// Different zeros using the SameValue Comparison:
assert.deepStrictEqual(0, -0);
// AssertionError: 0 deepStrictEqual -0
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// - 0
// + -0

const symbol1 = Symbol();
const symbol2 = Symbol();
assert.deepStrictEqual({ [symbol1]: 1 }, { [symbol1]: 1 });
// OK, because it is the same symbol on both objects.
assert.deepStrictEqual({ [symbol1]: 1 }, { [symbol2]: 1 });
// Fails because symbol1 !== symbol2!
// AssertionError [ERR_ASSERTION]: Input objects not identical:
// {
// [Symbol()]: 1
// }

const weakMap1 = new WeakMap();
const weakMap2 = new WeakMap([[{}, {}]]);
Expand All @@ -364,8 +382,16 @@ weakMap3.unequal = true;

assert.deepStrictEqual(weakMap1, weakMap2);
// OK, because it is impossible to compare the entries

// Fails because weakMap3 has a property that weakMap1 does not contain:
assert.deepStrictEqual(weakMap1, weakMap3);
// Fails because weakMap3 has a property that weakMap1 does not contain!
// AssertionError: Input A expected to strictly deep-equal input B:
// + expected - actual
// WeakMap {
// - [items unknown]
// + [items unknown],
// + unequal: true
// }
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand Down Expand Up @@ -639,7 +665,9 @@ changes:
* `value` {any}

Throws `value` if `value` is not `undefined` or `null`. This is useful when
testing the `error` argument in callbacks.
testing the `error` argument in callbacks. The stack trace contains all frames
from the error passed to `ifError()` including the potential new frames for
`ifError()` itself. See below for an example.

```js
const assert = require('assert').strict;
Expand All @@ -652,6 +680,19 @@ assert.ifError('error');
// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
assert.ifError(new Error());
// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error

// Create some random error frames.
let err;
(function errorFrame() {
err = new Error('test error');
})();

(function ifErrorFrame() {
assert.ifError(err);
})();
// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
// at ifErrorFrame
// at errorFrame
```

## assert.notDeepEqual(actual, expected[, message])
Expand Down Expand Up @@ -834,7 +875,7 @@ assert.notStrictEqual(1, 2);
// OK

assert.notStrictEqual(1, 1);
// AssertionError: 1 notStrictEqual 1
// AssertionError [ERR_ASSERTION]: Identical input passed to notStrictEqual: 1

assert.notStrictEqual(1, '1');
// OK
Expand Down Expand Up @@ -880,40 +921,34 @@ assert.ok(1);
// OK

assert.ok();
// throws:
// "AssertionError: No value argument passed to `assert.ok`.
// AssertionError: No value argument passed to `assert.ok()`

assert.ok(false, 'it\'s false');
// throws "AssertionError: it's false"
// AssertionError: it's false

// In the repl:
assert.ok(typeof 123 === 'string');
// throws:
// "AssertionError: false == true
// AssertionError: false == true

// In a file (e.g. test.js):
assert.ok(typeof 123 === 'string');
// throws:
// "AssertionError: The expression evaluated to a falsy value:
// AssertionError: The expression evaluated to a falsy value:
//
// assert.ok(typeof 123 === 'string')

assert.ok(false);
// throws:
// "AssertionError: The expression evaluated to a falsy value:
// AssertionError: The expression evaluated to a falsy value:
//
// assert.ok(false)

assert.ok(0);
// throws:
// "AssertionError: The expression evaluated to a falsy value:
// AssertionError: The expression evaluated to a falsy value:
//
// assert.ok(0)

// Using `assert()` works the same:
assert(0);
// throws:
// "AssertionError: The expression evaluated to a falsy value:
// AssertionError: The expression evaluated to a falsy value:
//
// assert(0)
```
Expand Down Expand Up @@ -995,13 +1030,19 @@ determined by the [SameValue Comparison][].
const assert = require('assert').strict;

assert.strictEqual(1, 2);
// AssertionError: 1 strictEqual 2
// AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
// + expected - actual
// - 1
// + 2

assert.strictEqual(1, 1);
// OK

assert.strictEqual(1, '1');
// AssertionError: 1 strictEqual '1'
// AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
// + expected - actual
// - 1
// + '1'
```

If the values are not strictly equal, an `AssertionError` is thrown with a
Expand Down Expand Up @@ -1035,6 +1076,34 @@ each property will be tested for including the non-enumerable `message` and
If specified, `message` will be the message provided by the `AssertionError` if
the block fails to throw.

Custom error object / error instance:

```js
const err = new TypeError('Wrong value');
err.code = 404;

assert.throws(
() => {
throw err;
},
{
name: 'TypeError',
message: 'Wrong value'
// Note that only properties on the error object will be tested!
}
);

// Fails due to the different `message` and `name` properties:
assert.throws(
() => {
const otherErr = new Error('Not found');
otherErr.code = 404;
throw otherErr;
},
err // This tests for `message`, `name` and `code`.
);
```

Validate instanceof using constructor:

```js
Expand Down Expand Up @@ -1076,39 +1145,12 @@ assert.throws(
);
```

Custom error object / error instance:

```js
const err = new TypeError('Wrong value');
err.code = 404;

assert.throws(
() => {
throw err;
},
{
name: 'TypeError',
message: 'Wrong value'
// Note that only properties on the error object will be tested!
}
);

// Fails due to the different `message` and `name` properties:
assert.throws(
() => {
const otherErr = new Error('Not found');
otherErr.code = 404;
throw otherErr;
},
err // This tests for `message`, `name` and `code`.
);
```

Note that `error` cannot be a string. If a string is provided as the second
argument, then `error` is assumed to be omitted and the string will be used for
`message` instead. This can lead to easy-to-miss mistakes. Please read the
example below carefully if using a string as the second argument gets
considered:
`message` instead. This can lead to easy-to-miss mistakes. Using the same
message as the thrown error message is going to result in an
`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
a string as the second argument gets considered:

<!-- eslint-disable no-restricted-syntax -->
```js
Expand All @@ -1121,10 +1163,15 @@ function throwingSecond() {
function notThrowing() {}

// The second argument is a string and the input function threw an Error.
// In that case both cases do not throw as neither is going to try to
// match for the error message thrown by the input function!
// The first case will not throw as it does not match for the error message
// thrown by the input function!
assert.throws(throwingFirst, 'Second');
// In the next example the message has no benefit over the message from the
// error and since it is not clear if the user intended to actually match
// against the error message, Node.js thrown an `ERR_AMBIGUOUS_ARGUMENT` error.
assert.throws(throwingSecond, 'Second');
// Throws an error:
// TypeError [ERR_AMBIGUOUS_ARGUMENT]

// The string is only used (as message) in case the function does not throw:
assert.throws(notThrowing, 'Second');
Expand All @@ -1134,7 +1181,7 @@ assert.throws(notThrowing, 'Second');
assert.throws(throwingSecond, /Second$/);
// Does not throw because the error messages match.
assert.throws(throwingFirst, /Second$/);
// Throws a error:
// Throws an error:
// Error: First
// at throwingFirst (repl:2:9)
```
Expand Down