We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 509ba00 commit 2db8d3eCopy full SHA for 2db8d3e
1 file changed
tests/harness/assert.js
@@ -78,6 +78,14 @@ if (typeof assert.throws !== 'function') {
78
}
79
assert.throws(() => { throw new Error('oops'); }, /oops/);
80
assert.throws(() => { throw new TypeError('bad'); }, TypeError);
81
+assert.throws(
82
+ () => { const err = new Error('match me'); err.code = 'ERR_TEST'; throw err; },
83
+ { code: 'ERR_TEST', message: 'match me' },
84
+);
85
86
+ () => { throw new RangeError('validate me'); },
87
+ (err) => err instanceof RangeError && err.message === 'validate me',
88
89
threw = false;
90
try { assert.throws(() => { /* does not throw */ }); } catch { threw = true; }
91
if (!threw) throw new Error('assert.throws must throw when fn does not throw');
0 commit comments