`jest --only-changed` ignores changes to module mocks
See original GitHub issue🐛 Bug Report
jest --only-changed
does not take mocks into consideration when choosing the tests to run.
To Reproduce
Steps to reproduce the behavior (see example repo):
- module
./a
depends on module./b
- module
./b
is mocked in the test of './a` - you change the mock of module
./b
Expected behavior
Test of module ./a
is run when running jest --only-changed
.
The success of the test depends on changes of the mock file - so changing the mock should trigger the test - the same way as changing ./b
directly does.
The scenario is not uncommon - could happen when someone is extending the functionality of ./b
, or works on another module that depends on it.
Link to repl or repo
https://github.com/tomasz-sodzawiczny/jest-only-changed-vs-mocks
envinfo
Probably not important, but:
System:
OS: macOS 10.14.5
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 12.4.0 - ~/.nvs/node/12.4.0/x64/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvs/node/12.4.0/x64/bin/npm
npmPackages:
jest: ^24.9.0 => 24.9.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Bypassing module mocks - Jest
Jest allows you to mock out whole modules in your tests, which can be useful for testing if your code is calling functions...
Read more >jest(1) — jest — Debian unstable - Debian Manpages
Runs tests related to the current changes and the changes made in the last commit. Behaves similarly to `--onlyChanged`. [boolean]. -- ...
Read more >jest-meluski - npm
Mock by Default: Jest automatically mocks JavaScript modules, ... recommended to use jest -o or jest --onlyChanged which will find tests related to...
Read more >Manual mock not working in with Jest - Stack Overflow
Module mocks are hoisted when possible with babel-jest transform, so this will result in mocked module: import ModuleA from ".
Read more >Unit Testing - Webpack from Nothing
If `onlyChanged` is set by default, running jest with `--all` will force Jest to run all tests instead of running only tests related...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see an open PR for this. Any updates? @petevdp @SimenB I’d love to see this merged soon 🙂
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.