nyc --all option reporting wrong coverage results if all files are instrumented
See original GitHub issueExpected Behavior
nyc should show correct coverage results of all instrumented files with --all option.
For example, if i have a.js and b.js in my application, unit tests only load a.js the total coverage could show as some percentage based on functionalities tested. If any of those files remain uncovered they will be factored into the report with a default of 0% coverage.
Observed Behavior
This was the result i am getting with all option enabled, shows no coverage results for any files even it failed for the files touched by my test suite shown below:
If i disabled the --all option, it shows the coverage report for the files touched by test suite as shown below:
Troubleshooting steps
- still occurring when I put
cache: false
in my nyc config
{
cache: false,
all: true,
"exclude": ["./coverage/**", "./dist/**", "**/*.spec.ts"]
}
Environment Information
“istanbul-instrumenter-loader”: “^3.0.1”, “nyc”: “^15.1.0”,
i am using cypress test runner and istanbul-instrumenter-loader to instrument the source code with this configuration in webpack:
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
enforce: 'post',
include: require('path').join(__dirname, '..', 'src'),
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/,
/(ngfactory|ngstyle)\.js/,
]
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
I’m sorry I don’t use webpack so I can’t make direct recommendations. If it’s just a matter of getting the code instrumented then I assume webpack has a way to run babel 7, in that case the latest babel-plugin-istanbul is the best way to get coverage counters into your code.
hi @toaditoad I didn’t check that due to some reasons but you can try explore why the nyc output json have no source instrumentation code parts if we used --all option by deep dive in their source code. This is required if you want full code coverage report. I think community is not very much active currently !