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

Coverage report shows red highlights despite being covered in unit test. #4163

Closed
dashmug opened this issue Jul 31, 2017 · 3 comments
Closed

Comments

@dashmug
Copy link
Contributor

dashmug commented Jul 31, 2017

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

I am reporting a bug.

What is the current behavior?

I wrote unit tests for the following calculateStatus function that needs refactoring. I am very certain that most of it is covered (as can be seen by the green 1x - 36x on the left side of the report) and yet they are highlighted in red and the coverage stats seems to be incorrect.

screen shot 2017-07-31 at 4 46 21 pm

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.

Unfortunately, I cannot reproduce this. This exact function and its unit test was taken from an old project (with the same jest and typescript config and the coverage was working fine in that one). I have used --no-cache and yet the problem still persists for this particular project.

What is the expected behavior?

The lines that were covered will NOT be highlighted and will be treated as covered.

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

jest v20.0.4
yarn v0.27.5
typescript v2.4.2

Jest config

{
    "testEnvironment": "node",
    "collectCoverageFrom": [
      "src/**/*.ts",
      "!src/**/*.d.ts",
      "!**/__tests__/**"
    ],
    "coverageReporters": [
      "html"
    ],
    "mapCoverage": true,
    "transform": {
      "^.+\\.ts$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "testRegex": "(/__tests__/.*\\.(test|spec))\\.ts$",
    "moduleFileExtensions": [
      "ts",
      "js"
    ],
    "setupFiles": [
      "./test/console.js"
    ]
  }
@cpojer
Copy link
Member

cpojer commented Jul 31, 2017

Unfortunately without a concrete repro we won't be able to troubleshoot this. I'm happy to reopen if you find a way to provide one.

@cpojer cpojer closed this as completed Jul 31, 2017
@dashmug
Copy link
Contributor Author

dashmug commented Jul 31, 2017

@cpojer I am currently working on a repro repo (:-)). I'll comment here when it's ready.

Quick question though: Am I right in thinking that the green xx markers mean they are covered and shouldn't be highlighted in red?

@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 13, 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

No branches or pull requests

2 participants