Ts-jest: No coverage reports

Created on 29 Oct 2020  ·  26Comments  ·  Source: kulshekhar/ts-jest

💥 Regression Report

After updating from 26.4.0 -> 26.4.2, I get no more a valid coverage report in jest.

Last working version

Worked up to version: 26.4.0

Stopped working in version: 26.4.2

To Reproduce

Steps to reproduce the behavior:

  1. write your app with tests
  2. run the coverage report in jest (jest --coverage) with version 26.4.0
  3. update to 26.4.2
  4. run the coverage report again

Expected behavior

The coverage report should be shown as in version 26.4.0

envinfo

System:
    OS: MacOS 10.15.7

Npm packages:
    jest: 26.4.2
    typescript: 4.0.3
   @babel/core :  ^7.12.3 ,
   @babel/plugin-syntax-jsx :  ^7.12.1 ,
   @babel/preset-env :  ^7.12.1 ,
   @babel/preset-react :  ^7.12.1 ,
   @babel/preset-typescript :  ^7.12.1 ,
   babel-loader :  ^8.1.0 ,
Regression

Most helpful comment

Ok that is more than an issue indeed.

All 26 comments

duplicate with #2080 , please check the solution there

Maybe there this is a duplicate but not of the issue you refer to.

does it work if you clear jest cache ?

I cleared the cache, but it did not helped it...I tried several (to many to recall them all) things to bring it back, but only after the downgrade to 26.4.0 it worked again.

clear cache works for me with 26.4.3. What I did is:

  • Upgrade to 26.4.3
  • Run yarn jest --clearCache
  • Run test again and coverage shows.

I actually linked the wrong duplicated issue, already corrected the comment.

I will check it out by tomorrow and report back. Thanks so far!

Confirmed, it works! Thanks again!

I have found that clearing the jest cache only fixes the coverage for a single run of jest. Following jest runs produce no coverage again. Clearing the cache before every jest run doesn't sound like a viable solution. Would you consider that an issue @ahnpnl?

Ok that is more than an issue indeed.

@arty-name for some reasons I cannot reproduce anymore this issue with jest 26.6.3 and ts-jest 26.4.3.

Updated: ok I managed to get one reproduce scenario. Some repos I don't see the issue, weird.

I'm also experiencing this issue. (26.4.0 & 26.4.3).
It's weird, it's not 100% deterministic.
Doing npx jest --clearCache (as per advice above) didn't have any effect for me.
Using --no-cache flag for all my scripts using jest CLI did the trick.

@kamilmielnik same here, yesterday I could reproduce with one repo. Today the same repo, not reproducible anymore. Clear cache always fixes the issue.

@arty-name @kamilmielnik I have published 26.4.4-alpha.0 at tag next. Would you guys please try and let me know ?

It would have been embarrassing if you didn't mention the same thing before, but now I, too, cannot reproduce this issue even though I did no changes to the project. I tried with the alpha version, rolled back to the published version - no issues anymore. 🤷‍♂️

@arty-name does alpha version always work for you ?

I didn't have any issues with it so far

I will leave it for a few days, let me know if anything happens :)

We encountered this today, no combination of jest versions, ts-jest versions (including next or 26.4.0) or clearing cache could get it to work.

This was on MacOSX running node v12.16.3; I'm happy to try any variations locally to try and help diagnose.

Remove node_modules maybe ? I cannot reproduce it always either. It happens randomly for me. If 26.4.0 doesn't work, it will be jest issue.

It also started happening for me. We run 3000 tests with jest and 860 with karma.
At the end we merge coverages using nyc. After upgrade to ts-jest 26.4.3 issue started ocurring all the time regardless of the jest version

@Milancos you can try with next tag to see if it helps

@ahnpnl issue didn't occur again with 26.4.4-alpha.0

The 26.4.4-alpha.0 will stay for a few days. Please test and let me know if it is stable.

Remove node_modules maybe ? I cannot reproduce it always either. It happens randomly for me. If 26.4.0 doesn't work, it will be jest issue.

Updated to next and ran:

rm -rf node_modules && npm i && node_modules/jest/bin/jest.js --clearCache && npm run test:coverage

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

Still occurring, same on our CI runs. What version of jest have people managed to get it working with? I can try with the same jest version to try and narrow down the variables.

@freshly-pressed-trousers your case is about collectCoverageFrom is not configured properly I think

Bingo!

Had collectCoverageFrom down as "src/*.ts", should have been "src/*/.ts", bloody globs always trip me up! Thanks for your time & help. <3

Can confirm it works on my env with "next" now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artola picture artola  ·  3Comments

bruk1977 picture bruk1977  ·  3Comments

japhar81 picture japhar81  ·  3Comments

ozum picture ozum  ·  4Comments

Slessi picture Slessi  ·  3Comments