Angular CLI Tutorial
Angular CLI Useful Resources
Selected Reading
- Angular CLI - Code Coverage
- Angular CLI - ng xi18n
- Angular CLI - ng update
- Angular CLI - ng doc
- Angular CLI - ng config
- Angular CLI - ng analytics
- Angular CLI - ng add
- Angular CLI - ng e2e
- Angular CLI - ng test
- Angular CLI - ng lint
- Angular CLI - ng serve
- Angular CLI - ng run
- Angular CLI - ng build
- Angular CLI - ng generate
- Angular CLI - ng help
- Angular CLI - ng new
- Angular CLI - ng version
- Angular CLI - Environment Setup
- Angular CLI - Overview
- Angular CLI - Home
Angular CLI Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Angular CLI - Code Coverage
Angular CLI - Code Coverage
This chapter explains the syntax of code coverage command along with an example.
Syntax
The syntax for code coverage command is as follows −
ng test <project> --codeCoverage=true
ng test command allows to check code coverage using the test cases written. See the example below.
Move to an angular project updated using ng xi18n command. This chapter is available at
Now, run the test with codeCoverage command.Example
An example for ng code coverage command is given below −
>Node>TutorialsPoint> ng test --codeCoverage=true 10% building 2/2 modules 0 active07 06 2020 15:21:46.292:WARN [karma]: No captur ed browser, open http://localhost:9876/ 07 06 2020 15:21:46.299:INFO [karma-server]: Karma v4.4.1 server started at http ://0.0.0.0:9876/ 07 06 2020 15:21:46.300:INFO [launcher]: Launching browsers Chrome with concurre ncy unpmited 07 06 2020 15:21:46.312:INFO [launcher]: Starting browser Chrome 07 06 2020 15:21:55.456:WARN [karma]: No captured browser, open http://localhost :9876/ 07 06 2020 15:21:55.533:INFO [Chrome 83.0.4103 (Windows 7.0.0)]: Connected on so cket gJgRaX_rXI6ZqoAiAAAA with id 261512 ... Chrome 83.0.4103 (Windows 7.0.0): Executed 1 of 2 SUCCESS (0 secs / 0.053 secs) ... Chrome 83.0.4103 (Windows 7.0.0): Executed 2 of 2 SUCCESS (0.107 secs / 0.082 se cs) TOTAL: 2 SUCCESS =============================== Coverage summary =============================== Statements : 100% ( 8/8 ) Branches : 100% ( 0/0 ) Functions : 100% ( 3/3 ) Lines : 100% ( 6/6 ) ================================================================================
Now ng test command has created a coverage folder within the TutorialsPoint, the project folder and has prepared the coverage report in html format available as >Node>TutorialsPoint>coverage>TutorialsPoint>index.html.
Advertisements