Open cu8code opened 4 days ago
Is axios actually installed, or are you trying to mock a module that does not exist?
I realize I made a bit of a mess earlier and completely overlooked an important detail: the package actually needs to be installed! Totally makes sense, but for some reason, I thought we could just create a random module and mock its implementation out of thin air. This issue should probably be closed, but I’ll leave that decision to the maintainers. Apologies to everyone for the incovinience!
Maybe we should add a comment regarding that in the documentation (assuming there isn't one already)
We should also decide if we want to support mocking modules that do not exist. I don't think there is a technical reason we couldn't do it, but I don't know if that is something people actually want/need to do in the wild.
Version
v24.0.0-pre
Platform
Subsystem
No response
What steps will reproduce the bug?
This issue was observed inside the nodejs source code, when tying to create a benchmark create a file
benchmark/test_runner/mock-module.js
now copy this code
now run this using
./node --experimental-test-module-mocks benchmark/test_runner/mock-module.js
You will get this output
As you can we we are trying to create a mock 'axios' module but we receive the error
Cannot find package 'axios'
, which is unexpected as we are not even importing the module. The error is occurring because of the linet.mock.module
How often does it reproduce? Is there a required condition?
dose not need any special condition
What is the expected behavior? Why is that the expected behavior?
should create a mock module called
axios
What do you see instead?
their is an error, saying package 'axios' not found, which is very unexpected
Additional information
No response