Skip to content

Commit 30892c8

Browse files
Tirielapapirovski
authored andcommitted
test: fix require-deps-deprecation for installed deps
Test test-require-deps-deprecation.js was failing when user already had node installed with acorn in require.resolve range. Modified test to acknowledge the possibility and throw only if acorn is found in the deps directory. PR-URL: #17848 Fixes: #17148 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e6a401e commit 30892c8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/parallel/test-require-deps-deprecation.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ for (const m of deprecatedModules) {
3939
} catch (err) {}
4040
}
4141

42+
// Instead of checking require, check that resolve isn't pointing toward a
43+
// built-in module, as user might already have node installed with acorn in
44+
// require.resolve range.
45+
// Ref: https://github.com/nodejs/node/issues/17148
4246
for (const m of deps) {
43-
assert.throws(() => { require(m); }, /^Error: Cannot find module/);
47+
let path;
48+
try {
49+
path = require.resolve(m);
50+
} catch (err) {
51+
assert.ok(err.toString().startsWith('Error: Cannot find module '));
52+
continue;
53+
}
54+
assert.notStrictEqual(path, m);
4455
}

0 commit comments

Comments
 (0)