test: use assert.rejects · nodejs/node@3a6eba3 (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Commit 3a6eba3
test: use assert.rejects
This verifies that the test actually rejects at this point by using `assert.rejects` instead of `try / catch`. PR-URL: #27123Reviewed-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
File tree
1 file changed
lines changed
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -353,11 +353,13 @@ async function tests() { | ||
353 | 353 | assert.strictEqual(e, err); |
354 | 354 | })); |
355 | 355 | readable.destroy(err); |
356 | -try { | |
357 | -await readable[Symbol.asyncIterator]().next(); | |
358 | -} catch (e) { | |
359 | -assert.strictEqual(e, err); | |
360 | -} | |
356 | +await assert.rejects( | |
357 | +readable[Symbol.asyncIterator]().next(), | |
358 | +(e) => { | |
359 | +assert.strictEqual(e, err); | |
360 | +return true; | |
361 | +} | |
362 | +); | |
361 | 363 | } |
362 | 364 | |
363 | 365 | { |