There's more...

Now if you want to see the coverage percentage of all your unit tests, you can use the following command:

    npm run coverage

Right now we only have 1 unit test for our Home component as you can see is in color green and at 100%, all the other files are in red with 0% because those have not been tested yet:

Also, the coverage command generates an HTML version of the result. There is a directory called "coverage" and inside other called "Icov-report". If you open index.html in your browser, you will see something like this:

Get React Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.