When you run jest with --coverage but there are no tests, it shows error "Jest: Coverage data for global was not found."
Delete all test files e.g. *.test.js
Run jest --config=jest.json --coverage with below configuration in jest.json:
{
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": -10
}
},
"collectCoverageFrom" : [
"*.js"
]
}
A simple and clear error like "No tests found", or simply skipping coverage, or coverage report as usual (and failed 100%).
https://github.com/Tiendq/lego-part-loader
npx envinfo --preset jestSystem:
OS: macOS Sierra 10.12.6
Binaries:
Node: 10.0.0 - /usr/local/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
npmPackages:
jest: ^22.4.3 => 22.4.3
I'd like to try this if no one is on it 馃槃
Go for it :)
I'm looking into this issue and I can't seem to reproduce the issue so I'm quite lost.
I've run jest --config=jest.json --coverage on the repo that @Tiendq provided above and got the following message
No tests found
In /Users/jayhwang/Documents/bug-test
7 files checked.
testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 7 matches
Pattern: - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
There is no sign of Jest: Coverage data for global was not found.
I also tried it with the master branch of jest and got the following
No tests found
In /Users/jayhwang/Documents/bug-test
7 files checked.
testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 7 matches
Pattern: - 0 matches
You need to include --coverage
I did include coverage
jest --config=jest.json --coverage
@misoguy I couldn't reproduce it too :(, I checked package.json history and Jest version is still same.
I am getting same issue here, my case has one more option: --changedSince=master
I could reproduce @zlk89 case, it seems that there is something unstable here.
jest --config=jest.json --coverage --changedSince=master

I am getting same issue here, my case only in watch mode --watch.
...
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/tests/.*\\.spec\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"collectCoverage": true,
"coverageDirectory": "coverage",
"coverageThreshold": {
"global": {
"branches": 80,
"functions": 80,
"lines": 80,
"statements": -10
}
}
},
...
$ npx jest --watch
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Jest: Coverage data for global was not found.
$ npx envinfo --preset jest
System:
OS: macOS Sierra 10.12.6
CPU: x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Binaries:
Node: 10.0.0 - /usr/local/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 6.0.1 - /usr/local/bin/npm
npmPackages:
@types/jest: ^22.2.3 => 22.2.3
jest: ^22.4.3 => 22.4.3
@misoguy kindly ask if there is any update on this?
@zlk89 I'm sorry, lately I didn't really find time... Feel free to take this issue if you'd like, if not I'll try to find time to tackle this issue soon 馃槃
I also want to try it too but it won't be done quickly, I'm new to Jest codebase :) and it seems that the issue happens with many cases.
Here's where that error is thrown, should be able to add the check you need somewhere in that function with a nice explination
Most helpful comment
I'd like to try this if no one is on it 馃槃