Skip to content

Commit

Permalink
test: use assert.rejects
Browse files Browse the repository at this point in the history
This verifies that the test actually rejects at this point by using
`assert.rejects` instead of `try / catch`.

PR-URL: #27123
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
BridgeAR committed Apr 10, 2019
1 parent 3d6533e commit 3a6eba3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/parallel/test-stream-readable-async-iterators.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ async function tests() {
assert.strictEqual(e, err);
}));
readable.destroy(err);
try {
await readable[Symbol.asyncIterator]().next();
} catch (e) {
assert.strictEqual(e, err);
}
await assert.rejects(
readable[Symbol.asyncIterator]().next(),
(e) => {
assert.strictEqual(e, err);
return true;
}
);
}

{
Expand Down

0 comments on commit 3a6eba3

Please sign in to comment.