summaryrefslogtreecommitdiff
path: root/test/sequential
diff options
context:
space:
mode:
authorAli Ijaz Sheikh <ofrobots@google.com>2019-02-13 13:21:10 -0800
committerAli Ijaz Sheikh <ofrobots@google.com>2019-02-15 12:52:05 -0800
commita02e3e2d5f1f96f3c408270d45935afdd5d1fffc (patch)
treea279b109ed4c805a03396a1200fa14f62c6f13e0 /test/sequential
parent05cd1a0929441943ba2d90c210c2d8bd8560293f (diff)
downloadandroid-node-v8-a02e3e2d5f1f96f3c408270d45935afdd5d1fffc.tar.gz
android-node-v8-a02e3e2d5f1f96f3c408270d45935afdd5d1fffc.tar.bz2
android-node-v8-a02e3e2d5f1f96f3c408270d45935afdd5d1fffc.zip
lib: improve error message for MODULE_NOT_FOUND
Include the require stack in the reported error message. PR-URL: https://github.com/nodejs/node/pull/25690 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential')
-rw-r--r--test/sequential/test-module-loading.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js
index 6cfa4da04e..90ab1d4f4f 100644
--- a/test/sequential/test-module-loading.js
+++ b/test/sequential/test-module-loading.js
@@ -131,7 +131,7 @@ require('../fixtures/node_modules/foo');
assert.ok(my_path.path_func instanceof Function);
// this one does not exist and should throw
assert.throws(function() { require('./utils'); },
- /^Error: Cannot find module '\.\/utils'$/);
+ /^Error: Cannot find module '\.\/utils'/);
}
let errorThrown = false;
@@ -170,12 +170,13 @@ assert.strictEqual(require('../fixtures/registerExt2').custom, 'passed');
assert.strictEqual(require('../fixtures/foo').foo, 'ok');
// Should not attempt to load a directory
-try {
- tmpdir.refresh();
- require(tmpdir.path);
-} catch (err) {
- assert.strictEqual(err.message, `Cannot find module '${tmpdir.path}'`);
-}
+assert.throws(
+ () => {
+ tmpdir.refresh();
+ require(tmpdir.path);
+ },
+ (err) => err.message.startsWith(`Cannot find module '${tmpdir.path}`)
+);
{
// Check load order is as expected