Not able to exclude files from coverage using nyc setup running on a create-react-app application
raphaelmatori opened this issue · comments
I'm using @cypress/instrument-cra": "^1.3.2" and I have noticed that even setting
nyc": { "exclude": [ "src/serviceWorker.js" ] }
on my package.json, the "src/serviceWorker.js" file still appearing on nyc's coverage page report.
When running directly with "nyc report --reporter=lcov", it works like a charm.
Same here, include
and exclude
seem to be ignored from the report initially generated.
Confirming that include
and exclude
does not work on my end either.
Same, have tried configuring in both package.json
and in .nycrc
. In the same vein, providing a list of file extensions to nyc does not work (.ts files are not recognized in the coverage report, even though I have added "extension": [".js", ".ts"]
to my nyc configuration block). I recognize the second item is not a documented part of this library, but it would be a useful addition.
Can I please see a public repo with a reproducible example?
Hi @bahmutov. I created a repo with a reproducible example at https://github.com/rupert-ong/instrument-cra-bug.
Just try extending your package.json by adding extra line "excludeAfterRemap": true in nyc like this:
"nyc": {
"exclude": [...],
"excludeAfterRemap": true
}
Is there a solution for this issue? v1.4.0 still exhibits this behavior. Exclude is completely ignored. I tried adding the excludeAfterRemap setting but that didn't solve the issue.
I had the same issue with my CRA and adding "all": true before include and exclude fixed the issue.
"nyc": {
"all": true,
"include": ["src/pages/.js", "src/components///.js", "src/components///*.jsx"],
"exclude": ["src/components/mocks"]
}
I´m having the same problem, even with the example project just add the exclude but it´s not working:
But the index.js still showing in coverage list fo files from the Chrome Browser:
The final coverage report still has the index.js, there´s no way to exclude files:
I have tried these but are not working:
- .nycrc.json (exclude not working)
- .babelrc (exclude not working)
Has anyone tried to do it? maybe an older version without this bug?
I'm still having this issue following all the suggested solutions above, any workaround please ?
@ibrahimsTailorMed
In your cypress.config you can add this it works the only problem is you can't write the path only you can write the names of the files you want to delete.
env: {
codeCoverage: {
exclude: [
"SignIn.js",
"index.js",
],
},
},
@bahmutov is there any update on this issue? I am using cypress V10.9.0.