Skip to content

Commit

Permalink
test: invalid package.json causes error when require()ing in directory
Browse files Browse the repository at this point in the history
Requiring a file from a directory that contains an invalid package.json
file should throw an error.

PR-URL: #10044
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Sam Shull authored and MylesBorins committed Feb 1, 2017
1 parent 22226fa commit e7c4dfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/fixtures/packages/invalid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.ok = 'ok';
1 change: 1 addition & 0 deletions test/fixtures/packages/invalid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{,}
7 changes: 7 additions & 0 deletions test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ assert.strictEqual(threeFolder, threeIndex);
assert.notStrictEqual(threeFolder, three);

console.error('test package.json require() loading');
assert.throws(
function() {
require('../fixtures/packages/invalid');
},
/^SyntaxError: Error parsing \S+: Unexpected token ,$/
);

assert.strictEqual(require('../fixtures/packages/main').ok, 'ok',
'Failed loading package');
assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok',
Expand Down

0 comments on commit e7c4dfb

Please sign in to comment.