-
Notifications
You must be signed in to change notification settings - Fork 19
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
Error when mocking core modules with the node:
prefix (minor annoyance)
#115
Comments
@gmahomarf thanks for the great PR which will be published soonish #116 This temporary work-around was needed for now. The long-term solution is for resolvewithplus to return the final path always with the protocol like import.meta.resolve would. Probably resolvewithplus can be updated before next-week, diff --git a/src/esmockModule.js b/src/esmockModule.js
index 1df6117..297a9ae 100644
--- a/src/esmockModule.js
+++ b/src/esmockModule.js
@@ -18,7 +18,9 @@ const FILE_PROTOCOL = 'file:///'
// https://url.spec.whatwg.org/, eg, file:///C:/demo file:///root/linux/path
const pathAddProtocol = (pathFull, protocol) => {
if (!protocol)
- protocol = !resolvewith.iscoremodule(pathFull) ? FILE_PROTOCOL : 'node:'
+ protocol = /^node:/.test(pathFull)
+ ? ''
+ : !resolvewith.iscoremodule(pathFull) ? FILE_PROTOCOL : 'node:'
if (protocol.includes(FILE_PROTOCOL))
pathFull = fs.realpathSync.native(pathFull)
if (process.platform === 'win32') |
it is published to [email protected] |
this seems to be resolved but feel free to reopen if necessary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context:
Trying to do something like the following:
Results in the following error:
This works without changing
someModule.js
:However, now the module URLs in the tests and the original module are different. I've opened a PR in iambumblehead/resolvewithplus#27 to add support for the
node:
prefix.The text was updated successfully, but these errors were encountered: