O'Reilly logo

React 16 Tooling by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit test coverage

Jest comes with built-in support for test coverage reporting. It's nice to have this included as part of your test framework because not all of them have this support. If you want to see what your test coverage looks like, simply pass the --coverage option when starting Jest as follows:

npm test -- --coverage 

When you do this, tests are run as normal. Then, the coverage tool inside Jest will figure out how well your tests cover your source, and will produce a report that looks like this:

----------|--------|----------|---------|---------|----------------|
File      |% Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|--------|----------|---------|---------|----------------|
All files | 2.17 | 0 | 6.25 | 4.55 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required