When writing tests it can often prove difficult to ensure we have sufficient coverage across all our code.
In this section we will look at using a coverage report to allow us to determine if further testing is required.
Generating a report
It is first important to ensure the tests are passing and to a high standard. Read the testing section more information.
Once that is done a coverage report can be generated by simply running: npm run coverage.
Running a coverage report will create a coverage directory where the generated files are stored.
Please ensure coverage folder has been .gitignored.
Viewing a report
To see the results of the report you will need to locate the index.html file that will have been generated and placed in the coverage folder and open this in your browser.
Understanding a report.
Once open you will see a breakdown of the project and an indicator as a percentage of how good the test coverage is. We strive to maintain a code coverage of at least 80%.
Where code coverage is not up to that standard we can click individual sections and drill down further so we are able to easily see which aspects of the code require further testing.