How to read Test Coverage report generated using Jest.

Jest come with functionality of generating report which help us in understanding test coverages. this coverage include statement , functional , branch coverages.

This is one example of test coverage report generated for test react app. This Report says it has 84% statement coverage , 100% branches and 100% functional and 84% lines coverage overall. than it display component wise report.

so what is mean of statement, Branches , functions , lines coverages etc.

  • Function coverage Has each function (or subroutine) in the program been called?

For each case, the percentage represents executed code vs not-executed code, which equals each fraction in percent format (e.g: 50% branches, 1/2).

Further we can click individual component or src file and see specific file report

For example index.js , no statement has covered.

In the file report:

  • 'E' stands for 'else path not taken', which means that for the marked if/else statement, the 'if' path has been tested but not the 'else'.

It also provides some color codes -

Pink: statements not covered.

Orange: functions not covered.

Yellow: branches not covered.

So Test coverage help us to understand how effective our test cases are , Are we covering whole source or not.

Angular,Vuejs,Android,Java,Git developer. i am nerd who want to learn new technologies, goes in depth.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store