Skip to content

Commit 518b133

Browse files
committed
tests: fix test-require-deps-deprecation for already 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. Fixes: nodejs#17148 Refs: nodejs#17148 (comment)
1 parent 81c2b59 commit 518b133

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ for (const m of deprecatedModules) {
3939
} catch (err) {}
4040
}
4141

42+
// Instead of checking require, check that resolve isn't pointing toward
43+
// /node/deps, as user might already have node installed with acorn in
44+
// require.resolve range
4245
for (const m of deps) {
43-
assert.throws(() => { require(m); }, /^Error: Cannot find module/);
46+
let path;
47+
try {
48+
path = require.resolve(m);
49+
} catch (err) {
50+
continue;
51+
}
52+
assert.notStrictEqual(path, m);
4453
}

0 commit comments

Comments
 (0)