istanbuljs / nyc

the Istanbul command line interface

Home Page:https://istanbul.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to include files with 0% coverage in all files coverage?

annahansen229 opened this issue · comments

I am using nyc for coverage in a CRA application following this tutorial.

I was able to set my nyc configuration to instrument all files in the application so that they show up in the coverage report even if they aren't tested.

To illustrate my question, here is an example of my coverage report (I have to redact the file names to comply with my NDA). You can see that the 78.24% statement coverage for all files is the aggregate of all lines that are not greyed out, 1639/2090.
MicrosoftTeams-image (14)

I have a number of files that are still untested, these are the greyed out lines. I want the all files coverage percentage to be reduced by the uncovered statements in those files. Say for example there was a total of 1000 statements within those files, then my coverage would be 1639/3090 or 53.04 %.

I've looked through the nyc configuration options and didn't find anything that would make this happen. Is this an available option?

Here is the configuration settings I'm currently using:

"nyc": {    
  "all": true,    
  "excludeAfterRemap": true,    
  "include": "src/**/*",    
  "exclude": [      
    "cypress/**/*",      
    "src/tests/**/*"    
  ]  
}

@annahansen229 I noticed the same issue. Were you able to find a solution for this?