MENU

Fun & Interesting

Reveal testing weakspots in your JavaScript code with Jest Coverage

Swashbuckling with Code 12,303 4 years ago
Video Not Working? Fix It Now

If you've ever been stuck on what tests to write for your code, Jest's coverage reports can be a great tool for showing what sections of your codebase are not tested yet. It becomes even more powerful when used in combination with Continuous Integration (CI), as it can be automated and even block pull requests from merging, which we'll show in this video. ~~~~~~ 00:00 - What we'll cover 01:09 - Project overview 03:10 - When is coverage useful? 08:04 - Exploring the report in the browser 15:25 - Increasing coverage with a test 20:20 - Covering conditionals (branches) 24:49 - Gotchas with random outcomes in tests 28:32 - Adding a config for coverage customization 33:58 - Expanding coverage on a previously untested file 36:44 - Failing a test run on poor coverage 43:05 - Pull request workflow example (CI) 52:50 - Wrap-up ~~~~~~ Follow Jimmy Cleveland's doings: twitter: https://twitter.com/JimmyDCleveland blog: https://blog.jimmydc.com/ #ci #jest #coverage

Comment