after upgrading to jest 24.0.0 and running "npm test" on my moderate-sized projects no longer show file-level metrics in the coverage summary and the "All Files" aggregates are all 0 (% Stmts, % Branch, % Funcs, %Lines), even though the tests cover the files at 100% for all files. if I simply downgrade to jest 23.6.0 (and change nothing else) then the coverage details show up.
git clone https://github.com/SamMaxwell/jest-issue-7734.git
npm i
npm test
_notice that the coverage summary is wrong_
npm uninstall jest
npm i [email protected] --save-dev
npm test
_notice that the coverage summary shows the correct metrics_
git clone https://github.com/SamMaxwell/jest-issue-7734.git
The console output has a coverage summary that includes file test coverage data and "All Files" aggregates that aren't all 0
Would you mind setting a repro we can test?
npm i (to get jest 24.0.0)
npm test (see that the coverage metrics are all 0)
npm uninstall jest
npm i [email protected] --save-dev
npm test (see that the coverage metrics are all 100)
I think 24.0.0 messed up coverage in general. I even commented out some tests to see if it would report the uncovered lines and it still did not report anything. (but works as expected in 23.6.0)
The problem is with collectCoverageFrom
.
Jest uses library micromatch for glob matching. It got updated(https://github.com/facebook/jest/pull/6650) to a new version in Jest 24. This new version does not match with .js
files with the pattern from your config('**/*.{js}'
).
I have reproduced this in the repl below:
https://repl.it/repls/BlankNotableAbility
If you change the pattern to '**/*.js'
or '**/*.{js,}'
, it will work.
Thanks @grosto for checking that out. Yup we've upgraded micromatch
to v3, so make sure your globs are valid.
Thanks @grosto and @thymikee, the new globs made it work as expected
Most helpful comment
The problem is with
collectCoverageFrom
.Jest uses library micromatch for glob matching. It got updated(https://github.com/facebook/jest/pull/6650) to a new version in Jest 24. This new version does not match with
.js
files with the pattern from your config('**/*.{js}'
).I have reproduced this in the repl below:
https://repl.it/repls/BlankNotableAbility
If you change the pattern to
'**/*.js'
or'**/*.{js,}'
, it will work.