Skip to content

Commit b6e174b

Browse files
alejandronaneztargos
authored andcommitted
test: use assert.throws() in test-require-json.js
Use assert.throws() instead of try/catch. PR-URL: #28358 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 3e63429 commit b6e174b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/parallel/test-require-json.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ require('../common');
2424
const assert = require('assert');
2525
const fixtures = require('../common/fixtures');
2626

27-
try {
27+
assert.throws(function() {
2828
require(fixtures.path('invalid.json'));
29-
} catch (err) {
30-
assert.ok(
31-
/test[/\\]fixtures[/\\]invalid\.json: /.test(err.message),
32-
`require() json error should include path: ${err.message}`);
33-
}
29+
}, {
30+
name: 'SyntaxError',
31+
message: /test[/\\]fixtures[/\\]invalid\.json: /,
32+
});

0 commit comments

Comments
 (0)