How it works...

If you run npm run coverage, you'll get both a text output and a HTML one. The former looks like what's shown in the following screenshot; you'll have to accept that in reality, lines are colored green, yellow, or red, depending on the achieved degree of coverage.

In our case, we got quite a lot of red since we only wrote a few tests, instead of going for a full test suite; you may work on completing it on your own, as an exercise for the reader!

 The colored ASCII output shows the coverage evaluations for all of our source code files; green means good coverage, yellow a medium one,
and red means a poor result. Since we only wrote a few tests, we are getting plenty of red!

If you open the /coverage/lcov-report/index.html file in a browser, you'll get the same sort of result as in the Node chapter, as follows:

The HTML output lets you browse the directories and files of your project. If you click on a specific file, you can even see which lines and functions were executed, and which were skipped by your tests.
If you want, you can even use the coverageThreshold configuration object to specify coverage levels that must be reached, in order for the tests to be considered sufficient; see https://jestjs.io/docs/en/configuration.html#coveragethreshold-object for more on this.

We have now finished working with React and Redux, we've looked at how to build web applications, and we've used our previously developed Node server backend. Let's move on to other types of development, starting with mobile applications, also with JS!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.42.94