diff --git a/test/fixtures/packages/invalid/index.js b/test/fixtures/packages/invalid/index.js new file mode 100644 index 00000000000000..014fa39dc365d1 --- /dev/null +++ b/test/fixtures/packages/invalid/index.js @@ -0,0 +1 @@ +exports.ok = 'ok'; diff --git a/test/fixtures/packages/invalid/package.json b/test/fixtures/packages/invalid/package.json new file mode 100644 index 00000000000000..004e1e20324524 --- /dev/null +++ b/test/fixtures/packages/invalid/package.json @@ -0,0 +1 @@ +{,} diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 2f4a85748ec03e..6125eefc360f00 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -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',