question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting all "Unknown% ( 0/0 )" in coverage results

See original GitHub issue

Environment

  1. node -v: v10.13.0

  2. npm -v: 6.4.1

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@24.1.0

  4. your vscode-jest settings if customized:

    • jest.pathToJest? Do not have
    • jest.pathToConfig? Do not have
    • in jest.config.js:
      collectCoverage: true, collectCoverageFrom: [‘ClientApp/src/**/*.{js,vue}’], coverageReporters: [‘text-summary’],
    • in settings.json: “jest.rootPath”: “web”, “jest.debugMode”: true, “jest.showCoverageOnLoad”: true,
  5. Operating system: Windows 10

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line? (for example: npm run test or node_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:

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================

(This also prevents me from seeing any red highlights for coverage in VS Code text editors.)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:8

github_iconTop GitHub Comments

7reactions
rickyblahacommented, Aug 9, 2019

I had the same issue, running npm test -- --coverage resulted in 0 statements found in the text report.

But by simply adding the CI=1 environment variable so jest does not run in interactive mode, it produced the expected coverage reports: CI=1 npm test -- --coverage

4reactions
spyros-ukcommented, Jun 21, 2019

Same issue here, I am using CRA with Typescript and rescripts.

Dependencies

node: v10.15.0
npm: 6.4.1
react-scripts: 3.0.1
typescript: 3.4.5
@rescripts/cli: 0.0.10

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]
}

Result: coverage_terminal

coverage_html
Read more comments on GitHub >

github_iconTop Results From Across the Web

Karma , Istanbul - code coverage report Unknown% ( 0/0 )
When the coverage is Unknown% that means you've probably enabled it correctly. Make sure the ...
Read more >
Python coverage always unknown - GitLab CI/CD
Hey, I am trying to make test coverage work for a python project. And I simply cannot figure out why there is no...
Read more >
Generic code coverage report refers to a file with an unknown ...
When trying to upload an object-C/Swift project, the sonar scanner returns error with Line 2 of report refers to a file with an...
Read more >
Code Coverage - Cypress Documentation
If you are unfamiliar with code coverage or want to learn more, ... and get instrumented code without an intermediate folder, but the...
Read more >
These medical bills are now banned. What to do if you get one ...
Sometimes insurers offer partial out-of-network coverage but leave ... ER or gets care at an in-network hospital, they should examine all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found