From 3a6eba3de60e6ae3bf8d99b1f502f5c26cdead2f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 7 Apr 2019 18:44:09 +0200 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell --- .../parallel/test-stream-readable-async-iterators.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index 99b40d368f8c33..b50a6b1734b32b 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -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; + } + ); } {