-
Notifications
You must be signed in to change notification settings - Fork 294
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
Getting all "Unknown% ( 0/0 )" in coverage results #433
Comments
I feel I must have some configuration wrong to get coverage to work, but not sure what it could be. I've done everything I can think of that the README points to. Any help to point me toward further setup for coverage would be appreciated. |
I'm having the same problem. It seems that actually after the initial test run, for a brief moment the coverage data is correct - however directly after it enters watch mode and reruns a test it immediately discards the previous result and outputs a coverage with no files and thus also 0 lines etc. (Additionally, I'm using TypeScript with babel-jest, but that shouldn't have an impact on this) |
Same issue here.
|
Same issue here, I am using CRA with Typescript and rescripts. Dependencies
Jest config {
...config,
setupFiles: ["<rootDir>//test/jest-config/setup.js"],
testURL: "http://localhost",
collectCoverage: true,
coverageReporters: ["json", "html"],
collectCoverageFrom: ["<rootDir>/src/**/*.{ts,tsx,js,jsx}"],
testEnvironment: "node",
transformIgnorePatterns: [
"<rootDir>/node_modules/(?!(lodash-es|react-apollo)/).+\\.(mjs|js|jsx|ts|tsx)$"
],
transform: {
...config.transform,
"^.+\\.(graphql|gql)$": "jest-transform-graphql"
},
moduleFileExtensions: [...testExtensions, ...prevTestExtensions]
} |
Let us know what you find... |
I had the same issue, running But by simply adding the CI=1 environment variable so jest does not run in interactive mode, it produced the expected coverage reports: |
This sounds like some good answers. I will perhaps try them later, but I'm moving on for now. |
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
Add scripts for CI and for local code coverage - test:ci for CI - test:cov to see code coverage locally. Because running with coverage slows down the test suite, this was added as an optional script. The --watchAll flag was added to `test:cov` because there is an issue where coverage reports 0/0% when tests run in interactive mode. jestjs/jest#7331 jest-community/vscode-jest#433 Have ESLint and Git ignore the coverage output Add tests for the App component Update README with unit test instructions
I also had the 0% coverage problem when running jest with the --config= option. The problem was that jest assumes the My solution was simply to go higher in the directory tree: {
"rootDir": "../.",
...
} |
any of this worked? |
Environment
node -v
: v10.13.0npm -v
: 6.4.1npm ls jest
ornpm ls react-scripts
(if you haven’t ejected): [email protected]your vscode-jest settings if customized:
collectCoverage: true,
collectCoverageFrom: ['ClientApp/src/**/*.{js,vue}'],
coverageReporters: ['text-summary'],
"jest.rootPath": "web",
"jest.debugMode": true,
"jest.showCoverageOnLoad": true,
Operating system: Windows 10
Prerequisite
npm run test
ornode_modules/.bin/jest
) These all work well, showing code coverage summary with interesting results:npm run test
npm test -- --coverage
node node_modules/jest/bin/jest.js
Steps to Reproduce
Start VS Code with a solution with tests. Run the tests by the command "Jest: Start Runner" in VS Code. Look into the Jest output window and see the tests run.
Relevant Debug Info
I get no errors or issues in the Jest output window or in the developer console.
Expected Behavior
Tests run and pass/fail appropriately in VS Code, and I should get a coverage report in the Jest output window with meaningful results
Actual Behavior
Tests run and pass/fail appropriately in VS Code, but I get:
(This also prevents me from seeing any red highlights for coverage in VS Code text editors.)
The text was updated successfully, but these errors were encountered: