I am running the following command to unit test and generate code code coverage report.
ng test --code-coverage
It is working fine and writing code coverage report in coverage
folder.
In this I got all files and directory coverage report
But I want to exclude specific files/directory let say src/app/quote/services/generated
. How to do that?
With Angular CLI 6, angular-cli.json has been renamed to angular.json which contains the configuration. In angular.json
, codeCoverage
expects a boolean value, which sets whether code-coverage should be done with every test run or not. To exclude files from code coverage, there is a property codeCoverageExclude
which accepts an array of files to be excluded from code coverage.
angular.json
"test": {
"options": {
"codeCoverageExclude": ["src/assets/vendor/**"],
...
},
...
}
rc.0
has been released. You should be able to add the code snippet below to ignore files.
Currently, you aren't able to do so in beta.32.3
. A change is coming to allow this to happen. In the next release (probably rc.0
), you will be able to do the following:
.angular-cli.json
"test": {
"codeCoverage": {
"exclude": [
"src/app/quote/services/generated/**/*"
]
},
...
}