jest --watch fails to determine files to run tests against if there are changes since last commit
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
We have an angular project using jest. Jest uses git to determine file changes and run tests against these files.
Clean project
If the project is “clean” with no change since last commit, then running jest --watch
starts properly. Then we can use it normally, it detects changes properly and run expected tests suits.
Dirty project
if the projects has changes on certain files since last commit and we try to run jest --watch
then Jest struggles to start and stay forever on the Determining test suites to run...
state. Any change after that doesn’t change the stuck jest state.
If we revert our changes (nothing to be commited) then retry to launch jest --watch
works. So it seems it’s a real problem with git changes detection by Jest.
Environment
This behavior is always encountered on windows. And sometimes on mac OS.
What is the expected behavior?
Being able to run jest --watch
even if there are modified files since last commit. If the changes files are not detected properly we expect to be able to even load jest and being able to pattern filter on the files we want.
Please provide your exact Jest configuration
module.exports = {
setupTestFrameworkScriptFile: "<rootDir>/src/setupJest.ts",
globals: {
'ts-jest': {
'tsConfigFile': 'src/tsconfig.spec.json'
},
'__TRANSFORM_HTML__': true
},
transform: {
'^.+\\.(ts|js|html)$': '<rootDir>/node_modules/jest-preset-angular/preprocessor.js',
},
testMatch: [
"**/__tests__/**/*.+(ts|js)?(x)",
"**/+(*.)+(spec).+(ts|js)?(x)"
],
moduleFileExtensions: [
'ts',
'js',
'html'
],
moduleNameMapper: {
"assets/(.*)": "<rootDir>/src/assets/$1"
},
transformIgnorePatterns: [
'node_modules/(?!@ngrx)'
],
coverageReporters: ['html', 'text-summary', 'text']
};
Run npx envinfo --preset jest
in your project directory and paste the
results here
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Binaries:
Yarn: 1.6.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 5.8.0 - C:\Program Files\nodejs\npm.CM
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 8.11.1 - /usr/local/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
npmPackages:
@types/jest: 22.2.3 => 22.2.3
jest: 22.4.3 => 22.4.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:19
Top GitHub Comments
@SimenB, I have added tracing to
jest
and was able to find root cause of the issue in my case. Please, see image below. There was an error insidejest-resolve-dependencies
and it was “eaten” without any reporting causingjest
to stuck.The problem was related to
coverage
folder (produced bykarma
), it contained some garbage butjest
was trying to work with it contents. I have added the following tojest.config.js
andjest
now works OK:jest-resolve-dependencies
error handling can be improved to not hide such errors. Thank you for your work on such great tool anyway.Oh. Should have read each comment here carefully. The issue is with the coverage folder. Apparently the coverage was referring to some old code that was deleted, and jest is still trying to find it. Deleting the coverage folder fixes the issue for me.