jest: Jest 22 fails to report coverage on ts files

Do you want to request a feature or report a bug? A bug

What is the current behavior? Coverage reporting fails

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior? Collect coverage information.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

We are right now using Jest 21 with ts-jest. When updating to Jest 22 it fails to report coverage. The output by jest is:

PASS src/text-input/index.style.test.tsx
FAIL src/text-input/index.style.test.tsx
  ● Test suite failed to run

    No file coverage available for: /x/x/x/src/text-input/index.style.test.tsx
      
      at CoverageMap.fileCoverageFor (node_modules/istanbul-lib-coverage/lib/coverage-map.js:96:15)
      at Array.forEach (native)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 24 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I use jest-preset-angular and the following config solved the issue to me in package.json:

"jest": {
...
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "index.ts"
    ]
...
}

Thanks for this forum.

For others encountering this issue via google search results, please check that the file referenced in the error message is always referenced in your app using the correct casing.

In my case, I was importing a component with a lowercase name, yet the file was uppercased. Changing the casing of the file fixed the problem.

I am on Windows as well.

@SimenB I was seeing the same problems as the original reporter and they are now fixed in 22.0.1 👍

A patch 22.0.1 has been released, could you please try that?