Under my Angular 6 I am running the following command to unit test and generate code code coverage report:
ng test --browsers=Chrome --watch=false --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 type of files let say :
all files which have the service prefix: *.service.ts
i ve told to do that in angular.json :
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "./karma.conf.js",
"codeCoverageExclude": ["src/*.service.ts"],
But that didn't work
Suggestions ?
In your Test.ts file you have to write this as below:
const context = require.context('', true, /\.component.spec\.ts$/);
context.keys().map(context);