Jest. Test coverage option

Ilya Zykin
2 min readJul 17, 2020

--

Here I’ll tell you about how to get a test coverage metric for an application where you use Jest for unit tests.

I’m joining a new project where a lot of code and tests. I found there is no too much information about how much tests are written and how well they cover the project. Let’s change that.

I found, it’s super easy to add coverage information with adding the following group of configurations in jest.config.js file

After I have run specs I see the report

If I go to the folder coverage/unit there I see an HTML report

I can click on a file and see uncovered places.

Looks just great!

Have a happy development!

--

--

Ilya Zykin
Ilya Zykin

Written by Ilya Zykin

IT coach. React and Rails enthusiast. Passionate programmer, caring husband and pancake baker on Sundays. School teacher of computer studies in the past.

No responses yet