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

Incorrect coverage report in 13.x and 14.x #1097

Closed
7 tasks done
ThWoywod opened this issue May 2, 2019 · 13 comments
Closed
7 tasks done

Incorrect coverage report in 13.x and 14.x #1097

ThWoywod opened this issue May 2, 2019 · 13 comments

Comments

@ThWoywod
Copy link

ThWoywod commented May 2, 2019

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

@JaKXz
Copy link
Member

JaKXz commented May 2, 2019

Can you provide a link to your repo or a minimal reproduction? Also can you follow the instructions here: https://npm.im/@istanbuljs/nyc-config-typescript and see if that fixes your issue?

@Codex-

This comment has been minimized.

@molant

This comment has been minimized.

@ThWoywod
Copy link
Author

ThWoywod commented May 3, 2019

Thank you for the really quick replay! I already tried @istanbuljs/nyc-config-typescript but it makes no differences. Depending on @istanbuljs/nyc-config-typescript I create my own nyc config like shown in the Issue. So the @istanbuljs/nyc-config-typescript don't work for me :-(

I already tried to revert to 13.* but the issue still occurs in my project.

Unfortunately, I can't reproduce this issue in a new demo project.

@JaKXz
Copy link
Member

JaKXz commented May 3, 2019

I have several examples of PRs I've made that simplify the nyc configuration in projects not reporting coverage with nyc-config-typescript and solving these kinds of issues... without a demo repository there's not much more help I can provide you other than suggesting you remove all the config you have and follow the instructions closely.

@JaKXz

This comment has been minimized.

@Codex-

This comment has been minimized.

@maleeb

This comment has been minimized.

@coreyfarrell
Copy link
Member

@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.

@coreyfarrell coreyfarrell changed the title Incorrect coverage report Incorrect coverage report in 13.x and 14.x May 6, 2019
@stale
Copy link

stale bot commented Jul 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 5, 2019
@stale stale bot closed this as completed Jul 12, 2019
@neilpalima
Copy link

The latest version 15.0.0 has this issue. Downgrading back to 14.1.1 works fine.

@Codex-
Copy link

Codex- commented Mar 20, 2020

What's your config? Probably need to raise a new issue

@neilpalima
Copy link

@Codex- I saw a latest issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants