Angular CLI code coverage and deployment in prod mode.

The CLI can run unit tests and create code coverage reports. Code coverage reports show you any parts of your code base that may not be properly tested by your unit tests.

To generate a coverage report run the following command in the root of your project.

content_copyng test --no-watch --code-coverage

When the tests are complete, the command creates a new /coverage folder in the project. Open the index.html file to see a report with your source code and code coverage values.

If you want to create code-coverage reports every time you test, you can set the following option in the CLI configuration file, angular.json:

content_copy"test": {
  "options": {
    "codeCoverage": true
  }
}

Once we have run our command we should be able to see:

Then we need to install globally the following:

npm install -g http-server

then we need to cd coverage folder and run the server

 http-server -c-1 . 

Now we should be able to check the port 8080

Last updated