Incorrect coverage report in 13.x and 14.x
See original GitHub issueI 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.

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: falsein my nyc config - setting tsconfig
sourceMap: truemakes 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
excludewithoutincludein 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

Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)

Top Related StackOverflow Question
@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.
@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-remapflag).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.