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.

Incorrect coverage report in 13.x and 14.x

See original GitHub issue

I try to get the test coverage from a more or less large Typescript project by using nyc. Nearly all my TypeScript files will have their own test files with many test cases.

In my option all this files should be covered by nyc. I try a lot with different nyc configurations and different versions of how to execute the test files.

At the beginning I start with a configuration where single files (which actually should have tests) will not appear in the coverage report. I could fix this issue by requiring “ts-node/register” and “source-map-support/register” to the nyc configuration. Now all files are listed in the coverage report but nyc think that there are no fitting tests.

image

I do not have any idea why this tests should not be covered. I try to reproduce it in a new bug-demo project but their, everything works well.

Troubleshooting steps

  • still occurrring when I put cache: false in my nyc config
  • setting tsconfig sourceMap: true makes no difference
  • set the typescript target to es6 makes no difference
  • execute tests with node, ts-node or jasmine-ts makes no difference
  • still occurrring when i only use exclude without include in my nyc config
  • using @istanbuljs/nyc-config-typescript makes no difference
  • using “ts-node/register/transpile-only” instead of “ts-node/register” will not work (it throws a “Cannot read property ‘loc’ of undefined” exception, see screenshot-2)

Environment Information

npx envinfo@latest --preset nyc
npx: Installierte 1 in 1.93s

  System:
    OS: macOS Mojave 10.14.4
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 130.55 MB / 16.00 GB
  Binaries:
    Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
    npm: 6.2.0 - ~/.nvm/versions/node/v10.9.0/bin/npm
  npmPackages:
    nyc: ^14.1.0 => 14.1.0 
    source-map-support: ^0.5.12 => 0.5.12 
    ts-node: ^8.1.0 => 8.1.0 
    typescript: ^2.9.2 => 2.9.2 



---
Jasmine: 2.99.0

NYC Configuration

"nyc": {
    "cache": false,
    "all": true,
    "sourceMap": true,
    "instrument": true,
    "exclude-after-remap": false,
    "extension": [
      ".ts"
    ],
    "check-coverage": true,
    "require": [
      "ts-node/register",
      "source-map-support/register"
    ],
    "include": [
      "app"
    ],
    "reporter": [
      "lcov",
      "text",
      "html"
    ],
    "exclude": [
      "**/*.d.ts",
      "coverage/**",
      "js/**",
      "builds/**",
      "config/**",
      "**/spec/**",
      "**/*.spec.ts",
      "**/node_modules/**",
      "gulpfile.js",
      "dummy-start.ts"
    ]
  },

screenshot-2 image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coreyfarrellcommented, May 6, 2019

@maleeb thanks for testing / responding.

The original poster of this issue has stated that downgrading to 13.x did not fix the issue, so all problems caused by upgrade to 14.x are off topic on this ticket. @Codex- please follow the suggestion from @maleeb (click Show Comment to see it).

All comments not related to OP’s issue are hidden as off topic so it’s easier to find information relevant to this specific issue. Unless your issue can be reproduced on 13.x or you have advice for that specific issue please do not post any further comments to this ticket, please open a new ticket instead.

1reaction
JaKXzcommented, May 6, 2019

@molant upon reviewing the webhint repo, it appears that it makes automatic upgrades without much review, so I think your claim of a regression might just be due to a breaking change between major versions (likely to do with the --exclude-after-remap flag).

Please read the changelog and the new documentation closely. Like I suggested for OP, I would recommend resetting your config entirely and starting with the preset that is appropriate for your project. As maintainers we don’t have the time to painstakingly investigate every repo like this, so we have been making a more concerted effort to update our documentation to support everyone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect coverage number reported by codecov - Bug Fixes
codecov is reporting 20.38% coverage and 293 lines missing coverage. But the file have very good amount of coverage and only about 15...
Read more >
Not able to integrate code coverage report with sonarqube
1 Answer 1 · Now, run ng test --code-coverage --watch=false command to generate code coverage. · Next step would be telling your sonar...
Read more >
PHPStorm 2020.2 - PHPUnit Code Coverage Incorrect
7 just yesterday. After doing so, the coverage report generated by PHPStorm is severely inaccurate. When I generate an HTML coverage report with ......
Read more >
Line coverage calculation seems incorrect? - SonarQube
On new code, the line coverage is correct (706 - 10) / 706 x 100% = 98,6%. But the condition coverage is way...
Read more >
Medicare Claims Processing Manual - Chapter 2 - CMS
To properly bill, hospitals other than CAHs assign type of bill (TOB) 13X to all bills for outpatient hospital services and TOB 14X...
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