-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
jest.mock slows down tests a lot #9025
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
Comments
Why would you expect test to run faster with a mock of super simple function/class? Mocking is not free, unfortunately. However, I'm pretty sure we could do something to make it faster, would you like to investigate? |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🐛 Bug Report
mocking module import slows down tests execution a lot.
To Reproduce
I've produced minimal public repo as I've spotted the issue at my work and I can't share the code here. Simply create a class which imports to another classes, creates its instances and uses them. The simpler, the better. Then write tests for a given class with mocking class constructor. test execution takes aprox. 6 second.
Expected behavior
The tests are expected to run faster with mocked classes than usual code execution
Link to repl or repo (highly encouraged)
https://github.com/WojtekF/jest-mock-example
envinfo
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
Binaries:
Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
The text was updated successfully, but these errors were encountered: