-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
How do I mock require('module/submodule') #553
Comments
If your module is located at |
@cpojer It is a npm module. I do I tried doing But neither of those cases work. |
Are you using npm3? |
Yes |
Unfortunately we don't have a good solution for this yet :( We aren't using npm3 at FB yet and I haven't been able to investigate this issue thoroughly yet. If you have an idea for a fix, I'd appreciate a pull request! |
I'm trying to mock |
Is there a development doc for Jest that I can take a look at? |
what kind of development doc are you looking for? I'm working on revamping the CONTRIBUTING guide. All you need to do is make a change and submit a PR on GitHub. Our bot will then ask you to sign the CLA. You can run jest on itself by doing |
For anyone else looking into this, you can now create a map with: Jest configuration:
Really, you can map it to any file. |
@Xesued is correct but I was unable to use the same kind of naming. I was trying to mock a file called HeaderStyleInterpolator.s from
|
this should be re-opened. It's still a problem and mocking via |
@cpojer @xeodou @jquense @StevePotter I recently opened this issue: #11136 Reading this thread, it seems it is not possible to mock Since Node.js 15 and later actually has promises as the first go-to for the Should I re-phrase my issue at #11136 slightly, or keep it as is? Because it does not seem to be a doc problem only. It also is not possible to mock, right? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
It says in the doc that we can create mock for node modules by placing
__mocks__
in the same directory as node_modules.How do I mock
require('module/submodule')
?I tried this:
and this:
where module.js would contain this:
but neither of these seem to work.
The text was updated successfully, but these errors were encountered: