Skip to content
Permalink
Browse files

test: use assert.throws() in test-require-json.js

Use assert.throws() instead of try/catch.

PR-URL: #28358
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
alejandronanez authored and targos committed Jun 21, 2019
1 parent 3e63429 commit b6e174b4f5c4b3e62274ba542640ddc6bc7ced7a
Showing with 5 additions and 6 deletions.
  1. +5 −6 test/parallel/test-require-json.js
@@ -24,10 +24,9 @@ require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');

try {
assert.throws(function() {
require(fixtures.path('invalid.json'));
} catch (err) {
assert.ok(
/test[/\\]fixtures[/\\]invalid\.json: /.test(err.message),
`require() json error should include path: ${err.message}`);
}
}, {
name: 'SyntaxError',
message: /test[/\\]fixtures[/\\]invalid\.json: /,
});

0 comments on commit b6e174b

Please sign in to comment.
You can’t perform that action at this time.