Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 620
Partha Sarathi Ghosh Avatar asked Feb 15 '17 05:02

Partha Sarathi Ghosh


People also ask

How do you exclude files from code coverage?

To exclude test code from the code coverage results and only include application code, add the ExcludeFromCodeCoverageAttribute attribute to your test class. To include assemblies that aren't part of your solution, obtain the . pdb files for these assemblies and copy them into the same folder as the assembly .

What is code coverage in angular testing?

Code coverage, also called test coverage, tells you which parts of your code are executed by running the unit and integration tests. Code coverage is typically expressed as percent values, for example, 79% statements, 53% branches, 74% functions, 78% lines.

What does NG test Command do?

ng testlink. Runs unit tests in a project.


1 Answers

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/**/*"], 
like image 87
Greg Avatar answered Sep 18 '22 10:09

Greg