Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix test-require-deps-deprecation for already installed deps #17848

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion test/parallel/test-require-deps-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ for (const m of deprecatedModules) {
} catch (err) {}
}

// Instead of checking require, check that resolve isn't pointing toward a
// built-in module, as user might already have node installed with acorn in
// require.resolve range.
// Ref: https://github.com/nodejs/node/issues/17148
for (const m of deps) {
assert.throws(() => { require(m); }, /^Error: Cannot find module/);
let path;
try {
path = require.resolve(m);
} catch (err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe restore the error message checking in the catch block?

  assert.ok(err.toString().startsWith('Error: Cannot find module ')`

assert.ok(err.toString().startsWith('Error: Cannot find module '));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d still like to see a continue here to avoid unneeded assertion in the following line.

continue;
}
assert.notStrictEqual(path, m);
}