istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.55k stars 353 forks source link

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

Open annahansen229 opened 1 year ago

annahansen229 commented 1 year ago

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/**/*"    
  ]  
}
ImanMahmoudinasab commented 8 months ago

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

annahansen229 commented 8 months ago

Nope

On Thu, Oct 26, 2023, 8:37 PM Iman Mahmoudinasab @.***> wrote:

@annahansen229 https://github.com/annahansen229 I noticed the same issue. Were you able to find a solution for this?

— Reply to this email directly, view it on GitHub https://github.com/istanbuljs/nyc/issues/1513#issuecomment-1782238273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH4JDZXD7IWG6LFR4KKRMFLYBMT7DAVCNFSM6AAAAAAVJ6NSZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSGIZTQMRXGM . You are receiving this because you were mentioned.Message ID: @.***>