diff options
author | Tom White <tomtinkerer@gmail.com> | 2018-10-05 15:00:16 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-10-07 17:14:43 -0700 |
commit | 13e6e01ce58cbd196846a9f90c0a79f2ccd758fc (patch) | |
tree | efc601472aa3ae906ece71bf4401d85e7a27bbec /test/sequential/test-module-loading.js | |
parent | 1d96d7da7331619ee99066451f6bcf1b5a7f3953 (diff) | |
download | android-node-v8-13e6e01ce58cbd196846a9f90c0a79f2ccd758fc.tar.gz android-node-v8-13e6e01ce58cbd196846a9f90c0a79f2ccd758fc.tar.bz2 android-node-v8-13e6e01ce58cbd196846a9f90c0a79f2ccd758fc.zip |
test: add module require tests for certain package.json errors
test for unusual error cases: verify that module require()
falls back to index if package.json names a missing file and
throws an error if package.json is unparseable.
PR-URL: https://github.com/nodejs/node/pull/23285
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@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 c71f9d1edf..42916a7903 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -104,6 +104,12 @@ const d2 = require('../fixtures/b/d'); assert.strictEqual(require('../fixtures/packages/index').ok, 'ok'); assert.strictEqual(require('../fixtures/packages/main').ok, 'ok'); assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok'); +assert.strictEqual(require('../fixtures/packages/missing-main').ok, 'ok'); + +assert.throws( + function() { require('../fixtures/packages/unparseable'); }, + /^SyntaxError: Error parsing/ +); { console.error('test cycles containing a .. path'); @@ -267,6 +273,7 @@ try { 'fixtures/packages/index/index.js': {}, 'fixtures/packages/main/package-main-module.js': {}, 'fixtures/packages/main-index/package-main-module/index.js': {}, + 'fixtures/packages/missing-main/index.js': {}, 'fixtures/cycles/root.js': { 'fixtures/cycles/folder/foo.js': {} }, |