Jest: coverage summary does not show data for 24.0.0

Created on 28 Jan 2019  路  7Comments  路  Source: facebook/jest

馃悰 Bug Report

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.

To Reproduce

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_

Link to repo

git clone https://github.com/SamMaxwell/jest-issue-7734.git

Expected behavior

The console output has a coverage summary that includes file test coverage data and "All Files" aggregates that aren't all 0

Regression Needs Repro

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.

All 7 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hramos picture hramos  路  3Comments

stephenlautier picture stephenlautier  路  3Comments

nsand picture nsand  路  3Comments

Secretmapper picture Secretmapper  路  3Comments

paularmstrong picture paularmstrong  路  3Comments