Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular CLI 6 coverage with --watch=false returns error

When I run

ng test --watch=false --code-coverage --no-progress

I get

Schema validation failed with the following errors:
  Data path ".watch" should be boolean.

I searched but can't find a hit for this error.

The docs (https://github.com/angular/angular-cli/wiki/test) clearly say --watch=false should work.

Other people say it works, for example https://github.com/angular/angular-cli/issues/10711#issuecomment-387704999

I'm on angular/cli 6.2.4. angular 6.1.9

Has anyone encountered this?

like image 821
Scott Johnson Avatar asked Oct 09 '18 19:10

Scott Johnson


People also ask

How do I check my karma coverage?

Code coverage enforcementlink To enable this, open the Karma test platform configuration file, karma. conf. js , and add the check property in the coverageReporter: key. The check property causes the tool to enforce a minimum of 80% code coverage when the unit tests are run in the project.

What is code coverage in angular?

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.

How do I check my code coverage?

To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.


2 Answers

Do you have more than one project in your angular workspace (angular.json)? I have received this error when running ng test --watch=false on a workspace with multiple projects.

You can run the test command on the project by name e.g.

ng run PROJECT_NAME:test --watch=false --code-coverage --no-progress

you need to substitute in the name of your project for PROJECT_NAME

like image 144
joshvito Avatar answered Oct 21 '22 19:10

joshvito


try singleRun: true, in karma.conf.js configuration, if you want the test to keep on watching for change and running the test automatically.

like image 39
Vivek Kumar Avatar answered Oct 21 '22 18:10

Vivek Kumar