Skip to content
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);
}