Angular-cli: ng test Istanbul code coverage report exclude files

Created on 24 May 2018  路  3Comments  路  Source: angular/angular-cli

In Angular 5.2, we can exclude the files from Istanbul code coverage report using .angular-cli.json with below code and it works fine.

"test": { "karma": { "config": "./karma.conf.js" }, "codeCoverage": { "exclude": [ XXX/X.ts", XXX/X.ts" ] } },

In Angular 6.0.3, we tried adding in angular.json with below code. But its not working.

"test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "karmaConfig": "./karma.conf.js", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "scripts": ["src/app/lib/hammerJs/hammer.js"], "styles": [], "assets": ["src/resources"], "codeCoverage": { "exclude": [ XXX/X.ts", XXX/X.ts" ] } } }

Versions

Angular CLI: 6.0.3
Node: 8.9.1
OS: darwin x64
Angular: 6.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.3
@angular-devkit/build-angular     0.6.3
@angular-devkit/build-optimizer   0.6.3
@angular-devkit/core              0.6.3
@angular-devkit/schematics        0.6.3
@ngtools/webpack                  6.0.3
@schematics/angular               0.6.3
@schematics/update                0.6.3
rxjs                              6.2.0
typescript                        2.8.3
webpack                           4.8.3

Most helpful comment

'codeCoverageExclude' property inside 'options' solved my problem.

All 3 comments

'codeCoverageExclude' property inside 'options' solved my problem.

Example of the solution:

"test": {
  "builder": "@angular-devkit/build-angular:karma",
  "options": {
    "main": "src/test.ts",
    ...
    "codeCoverageExclude": [
      "src/app/in-memory-data.service.ts",
      "src/test-util/stubs.ts"
    ]
  }
}

(using node v8.11.3 and ng v6.0.8)
Also see this for all supported parameters:
https://github.com/angular/angular-cli/blob/v6.0.0-rc.8/packages/%40angular/cli/lib/config/schema.json#L1065-L1267

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NCC1701M picture NCC1701M  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

hartjo picture hartjo  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments