Skip to content

Commit 6f2f02d

Browse files
Sam Shulladdaleax
Sam Shull
authored andcommitted
test: invalid package.json causes error when require()ing in directory
Requiring a file from a directory that contains an invalid package.json file should throw an error. PR-URL: #10044 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6489a91 commit 6f2f02d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports.ok = 'ok';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{,}

test/sequential/test-module-loading.js

+7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ assert.strictEqual(threeFolder, threeIndex);
6969
assert.notStrictEqual(threeFolder, three);
7070

7171
console.error('test package.json require() loading');
72+
assert.throws(
73+
function() {
74+
require('../fixtures/packages/invalid');
75+
},
76+
/^SyntaxError: Error parsing \S+: Unexpected token , in JSON at position 1$/
77+
);
78+
7279
assert.strictEqual(require('../fixtures/packages/index').ok, 'ok',
7380
'Failed loading package');
7481
assert.strictEqual(require('../fixtures/packages/main').ok, 'ok',

0 commit comments

Comments
 (0)