Skip to content

Commit 21f0577

Browse files
Gabriel SchulhofMylesBorins
Gabriel Schulhof
authored andcommitted
test: fix up N-API error test
Replace assert.throws() with an explicit try/catch in order to catch the thrown value and be able to compare it strictly to an expected value. Re: #20428 (comment) PR-URL: #20487 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 17e4c8b commit 21f0577

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/addons-napi/test_error/test.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,23 @@ assert.throws(() => {
6161
}, /^TypeError: type error$/);
6262

6363
function testThrowArbitrary(value) {
64-
assert.throws(() => {
65-
test_error.throwArbitrary(value);
66-
}, value);
64+
assert.throws(
65+
() => test_error.throwArbitrary(value),
66+
(err) => {
67+
assert.strictEqual(err, value);
68+
return true;
69+
});
6770
}
6871

6972
testThrowArbitrary(42);
7073
testThrowArbitrary({});
7174
testThrowArbitrary([]);
7275
testThrowArbitrary(Symbol('xyzzy'));
7376
testThrowArbitrary(true);
77+
testThrowArbitrary('ball');
78+
testThrowArbitrary(undefined);
79+
testThrowArbitrary(null);
80+
testThrowArbitrary(NaN);
7481

7582
common.expectsError(
7683
() => test_error.throwErrorCode(),

0 commit comments

Comments
 (0)