Code Coverage Report

In simple words, code coverage is a white-box testing method that shows the percentage of code that gets executed during test runs. It aids us in evaluating the extent to which our tests address the code and identify any potential gaps.

With HyperTest, you can achieve over 90% code coverage. When you run your tests through the HyperTest CLI, it generates a comprehensive code coverage report, clearly highlighting which code paths are covered and which ones need more attention.

1. Run Code Coverage from CLI

  • Go to your Visual Code Studio

  • Run the command :

    run-test-cov-html
  • After this, a coverage folder will be generated and a code coverage report will be displayedon your CLI along with the test result. This will give you a general idea on how many statements, branches, functions and lines are covered when your test ran.

2. View Coverage Folder

You can open this report on your browser to get a more granular view of how many lines have been covered by your code.

Go to the coverage folder and open the file .htConf.js.html in your browser.

  • Click on 'All Files' to view all of your code.

  • Open the file whose code coverage you want to take a look into.

  • Once you open your file, you will able to see the lines we have not covered marked in pink.

For the lines marked in pink, we just need some traffic and we will be able to cover these scenarios instantly.

Last updated