diff options
author | Sam Shull <sam+github@samshull.com> | 2016-12-01 09:55:07 -0800 |
---|---|---|
committer | Italo A. Casas <me@italoacasas.com> | 2016-12-07 10:00:11 -0500 |
commit | 4f486aa6617a642f2ff6e3e6e43f5e27c4bc8388 (patch) | |
tree | 6f52c35f2914e081b3d86f153cfa5e6094df06f6 /test/sequential/test-module-loading.js | |
parent | 00ea28680058d7632cb21b270efa561116a7afa7 (diff) | |
download | android-node-v8-4f486aa6617a642f2ff6e3e6e43f5e27c4bc8388.tar.gz android-node-v8-4f486aa6617a642f2ff6e3e6e43f5e27c4bc8388.tar.bz2 android-node-v8-4f486aa6617a642f2ff6e3e6e43f5e27c4bc8388.zip |
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: https://github.com/nodejs/node/pull/10044
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential/test-module-loading.js')
-rw-r--r-- | test/sequential/test-module-loading.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index f500700f9d..61746a282f 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 , in JSON at position 1$/ +); + assert.strictEqual(require('../fixtures/packages/index').ok, 'ok', 'Failed loading package'); assert.strictEqual(require('../fixtures/packages/main').ok, 'ok', |