angular cli exclude files/directory for `ng test --code-coverage`

Partha Sarathi Ghosh picture Partha Sarathi Ghosh · Feb 15, 2017 · Viewed 17.7k times · Source

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

enter image description here

But I want to exclude specific files/directory let say src/app/quote/services/generated. How to do that?

Answer

Greg picture Greg · May 14, 2018

With the latest CLI, inside 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/testing/**/*"],