test: use assert.rejects

This verifies that the test actually rejects at this point by using
`assert.rejects` instead of `try / catch`.

PR-URL: https://github.com/nodejs/node/pull/27123
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater 2019-04-07 18:44:09 +02:00
parent 3d6533ea02
commit 3a6eba3de6
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -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;
}
);
}
{