watch mode does not honor shouldRunTestSuite when there are changes
See original GitHub issue🐛 Bug Report
jest@23.6.0 ts-jest@23.10.1
When there are changes, even though jest-watch-suspend
returns false
in shouldRunTestSuite()
callback, tests are still executed.
To Reproduce
Use this branch: https://github.com/unional/issues/tree/jest-watch-git
After you clone and npm install
, run npm run watch
.
You will see no test is executed (expected result):
Determining test suites to run...
Test is suspended on start.
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press s to suspend watch mode.
› Press Enter to trigger a test run.
Now, do the following:
- edit
src/index.ts
to add a function, e.g.:
export function foo(x) { return x }
export function boo(y) { return y }
- create a copy of
src/r2/index.spec.ts
assrc/r2/index2.spec.ts
Now if you run npm run watch
, you will see the test in src/r2/index.spec.ts
is executed while Test is suspended on start.
is printed:
Determining test suites to run...
Test is suspended on start.
PASS src/r2/index.spec.ts
√ test demo (7ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.706s
Ran all test suites related to changed files.
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press s to suspend watch mode.
› Press Enter to trigger a test run.
The code that prints the “Test is suspended on start.” is here:
You can see that it is returning false. But in the example above, the test is still being executed.
Run npx envinfo --preset jest
Paste the results here:
System:
OS: Windows 10
CPU: x64 Intel(R) Xeon(R) CPU E5-4650 v4 @ 2.20GHz
Binaries:
Yarn: 1.9.4 - C:\Program Files\nodejs\yarn.CMD
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
reference: https://github.com/unional/jest-watch-suspend/issues/4
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
No coverage when running in watch mode #7331 - GitHub
The tests for those files won't be run because they haven't been changed since the last commit. Your coverage report will therefore be...
Read more >Watching Files for Changes - Node Tap
In this mode, tap will watch your project for changes to test files and the program files that they cover, and open a...
Read more >Run New and Failing Tests on File Change with Pytest
See how to pair Pytest and pytest-watch to run failing unit tests and new tests automatically on file changes without running the whole...
Read more >Jest CLI Options
This mode will send all other test output and user messages to stderr. --lastCommit . Run all tests affected by file changes in...
Read more >A Practical Guide To Testing React Applications With Jest
Jest has a nice feature called watch mode, which watches for file changes and runs tests accordingly. To run Jest in watch mode,...
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
Thanks for reporting, I’ll take a look tomorrow morning
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.