Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since Jest 23.2.0: "Coverage data for global was not found." #6563

Closed
Vinnl opened this issue Jun 27, 2018 · 12 comments · Fixed by #6661
Closed

Since Jest 23.2.0: "Coverage data for global was not found." #6563

Vinnl opened this issue Jun 27, 2018 · 12 comments · Fixed by #6661

Comments

@Vinnl
Copy link
Contributor

Vinnl commented Jun 27, 2018

🐛 Bug Report

This is going to be somewhat of a difficult bug report since there's many moving parts and I'm not sure which causes it, but since upgrading Jest from 23.1.0 to 23.2.0, I'm currently running into the following error on one of my projects:

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
Jest: Coverage data for global was not found.

Apart from the upgrade (which did encompass quite a few packages to be upgraded along with jest proper), nothing changed in my setup.

I'm using TypeScript with ts-jest, if relevant.

To Reproduce

$ git clone -b deps/update-46517a0f git@gitlab.com:Flockademic/Flockademic.git
$ yarn
$ yarn run jest

Unfortunately I wouldn't know how to reproduce this in a fresh repo...

Expected behavior

Tests to succeed (which is happening now) and coverage to be 100% everywhere.

Link to repl or repo (highly encouraged)

Not minimal unfortunately, but as I referenced above: git clone -b deps/update-46517a0f git@gitlab.com:Flockademic/Flockademic.git.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: Linux 4.13 Ubuntu 16.04.4 LTS (Xenial Xerus)
    CPU: x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  Binaries:
    Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
    Yarn: 1.7.0 - /usr/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
  npmPackages:
    @types/jest: 23.1.1 => 23.1.1
    jest: 23.2.0 => 23.2.0
@palmerj3
Copy link
Contributor

@Vinnl I suspect that this is due to ts-jest not being compatible with jest 23. There is an issue on the ts-jest repo to investigate compatibility. kulshekhar/ts-jest#589

@TheCodeDestroyer
Copy link

TheCodeDestroyer commented Jul 4, 2018

@palmerj3 I don't use types and I get the same error

Sent from my Nexus 5X using FastHub

@Rukeith
Copy link

Rukeith commented Jul 5, 2018

I got the same issue and I just use pure javascript.

@AodhanHayter
Copy link
Contributor

I'm having the same issue, dropping down to jest@22.4.4 resolves the issue. Any version at 23.x.x gives me the same problem. Maybe config options have changed?

@Rukeith
Copy link

Rukeith commented Jul 6, 2018

I notice 23.x.x add a options --coverage, but it still not work while I add to command line.

@jongear
Copy link

jongear commented Jul 6, 2018

With pure javascript, I also received the Jest: Coverage data for global was not found. error in jest@23.3.0

package.json for reference

 {
  "name": "my-package",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "test": "jest",
    "test:coverage": "jest --coverage",
    "report-coverage": "npm run test:coverage && cat ./coverage/lcov.info | codecov",
  },
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 50,
        "functions": 50,
        "lines": 50,
        "statements": 50
      }
    },
    "collectCoverageFrom": [
      "src/**/*.{js}",
      "!**src/config/*.{js}",
      "!**src/config/*/*.{js}",
      "!**src/docs/*.{js}",
      "!**src/models/*.{js}"
    ]
  },
  "devDependencies": {
    "codecov": "^3.0.3",
    "eslint": "^4.19.1",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-prettier": "^2.6.2",
    "jest": "^23.3.0",
    "prettier": "^1.13.7"
  }
}

For now, we have rolled back to jest@22.4.3 which works as expected

@Tvrqvoise
Copy link
Contributor

Tvrqvoise commented Jul 6, 2018

I've found the issue. As part of #6400, micromatch was upgraded from version ^2.3.11 to ^3.1.10. Between these major versions, micromatch appears to have more closely adhered to Unix glob, which means breaking changes. Jest uses this library for matching the configuration values in package.json such as collectCoverageFrom, and hence some configurations which worked previously will no longer work.

For example, @jongear, in micromatch@2 you could do something like src/**/*.{js}. However, in micromatch@3 single-item sets are invalid and must now be either src/**/*.js or src/**/*.{js,}. Likewise, the same problem exists in @Vinnl's library -- lib/lambda/faas.ts is matched by lib/**.{js,ts} in micromatch@2, but must be lib/**/*.{js,ts} in micromatch@3.

I'll open a PR to revert micromatch back down to version 2. Not sure if FB wants to go down this route or not, but at least it's something -- someone on the Jest team should probably advise.

In the meantime, individuals can fix their issue by assuring that your glob patterns work in version 3.

@Vinnl
Copy link
Contributor Author

Vinnl commented Jul 9, 2018

That's fantastic @Tvrqvoise, I don't know how you managed to track that down, but I can confirm that updating the glob patterns fixed it for me.

Although micromatch@3 is a year old now apparently, its CHANGELOG does mention that there should be no breaking changes. I guess this change does look reasonable, but if it would be reason for Jest to downgrade to v2, then maybe we should report it as an issue there as well?

@thymikee
Copy link
Collaborator

thymikee commented Jul 9, 2018

I think we should file a PR to the changelog within micromatch then. @Vinnl would be so kind?

@SimenB
Copy link
Member

SimenB commented Jul 9, 2018

I'm open to a revert, then upgrade it for Jest 24 along with the awesome explanation @Tvrqvoise provided about the gotchas. It's obviously super breaking, and landed in a minor (#6400).

Tvrqvoise added a commit to Tvrqvoise/jest that referenced this issue Jul 9, 2018
Tvrqvoise added a commit to Tvrqvoise/jest that referenced this issue Jul 9, 2018
AodhanHayter added a commit to AodhanHayter/jest that referenced this issue Jul 9, 2018
Due to breaking changes in an upgrade of the dependency micromatch
from ^2.3.11 to ^3.1.10 many users saw their coverage reporting
failing because their glob matching was in an unsupported format.

Adding the help text here gives users a good starting point for
debugging when they run into issues concerning this option. This should
help alleviate support issues created concerning this configuration
option.

Issue jestjs#6563 is a good example of what could be avoided in the future
with this addition to the documentation.
thymikee pushed a commit that referenced this issue Jul 9, 2018
## Summary

As part of #6400, `micromatch` was updated.  While `micromatch`'s CHANGELOG claims that this is safe, several regressions have been noted in cases where users relied upon invalid glob patterns.  For example, these patterns would all match `src/foo/bar/baz.js`, but no longer do:

 - `src/**/*.{js}`
 - `src/**.js`
 - `src/**/*.{js|ts}`

Fixes #6563
Fixes #6546

## Test plan

Unit tests were added which demonstrate the known cases.
AodhanHayter added a commit to AodhanHayter/jest that referenced this issue Jul 9, 2018
Due to breaking changes in an upgrade of the dependency micromatch
from ^2.3.11 to ^3.1.10 many users saw their coverage reporting
failing because their glob matching was in an unsupported format.

Adding the help text here gives users a good starting point for
debugging when they run into issues concerning this option. This should
help alleviate support issues created concerning this configuration
option.

Issue jestjs#6563 is a good example of what could be avoided in the future
with this addition to the documentation.
AodhanHayter added a commit to AodhanHayter/jest that referenced this issue Jul 9, 2018
…om (jestjs#6563)

Due to breaking changes in an upgrade of the dependency micromatch
from ^2.3.11 to ^3.1.10 many users saw their coverage reporting
failing because their glob matching was in an unsupported format.

Adding the help text here gives users a good starting point for
debugging when they run into issues concerning this option. This should
help alleviate support issues created concerning this configuration
option.
AodhanHayter added a commit to AodhanHayter/jest that referenced this issue Jul 9, 2018
Due to breaking changes in an upgrade of the dependency micromatch
from ^2.3.11 to ^3.1.10 many users saw their coverage reporting
failing because their glob matching was in an unsupported format.

Adding the help text here gives users a good starting point for
debugging when they run into issues rlated to this option. This will
help alleviate support issues (such as jestjs#6563) concerning this configuration
option.
narr added a commit to narr/narr-material-ui that referenced this issue Jul 10, 2018
@Vinnl
Copy link
Contributor Author

Vinnl commented Jul 11, 2018

Took me a while, but I reported an issue: micromatch/micromatch#133

(I did not submit a PR to the CHANGELOG yet, since I cannot exhaustively list the ways the globbing patterns have been restricted.)

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants