mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
assert: add warning about assert.doesNotReject
The usefulness of `assert.doesNotReject` is very limited and this warns against the usage. PR-URL: https://github.com/nodejs/node/pull/19462 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
@@ -321,10 +321,16 @@ added: REPLACEME
|
||||
* `message` {any}
|
||||
|
||||
Awaits for the promise returned by function `block` to complete and not be
|
||||
rejected. See [`assert.rejects()`][] for more details.
|
||||
rejected.
|
||||
|
||||
Please note: Using `assert.doesNotReject()` is actually not useful because there
|
||||
is little benefit by catching a rejection and then rejecting it again. Instead,
|
||||
consider adding a comment next to the specific code path that should not reject
|
||||
and keep error messages as expressive as possible.
|
||||
|
||||
When `assert.doesNotReject()` is called, it will immediately call the `block`
|
||||
function, and awaits for completion.
|
||||
function, and awaits for completion. See [`assert.rejects()`][] for more
|
||||
details.
|
||||
|
||||
Besides the async nature to await the completion behaves identically to
|
||||
[`assert.doesNotThrow()`][].
|
||||
|
||||
Reference in New Issue
Block a user