Reading Coverage Reports
You'll learn how to interpret coverage report output to identify untested code paths and understand what coverage percentages actually mean.
Understanding Coverage Metrics
When you generate a coverage report, you'll see four main metrics:
- Statement coverage: Percentage of executable statements run
- Branch coverage: Percentage of conditional paths taken (if/else, switch cases)
- Function coverage: Percentage of functions called
- Line coverage: Percentage of lines executed
Think of coverage like a map of your codebase where green areas show explored territory and red areas show places your tests never visited.
Reading the Report Output
Coverage tools typically show a table summary:
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Lines
-------------|---------|----------|---------|---------|----------------
calculator.js| 75.00 | 50.00 | 66.67 | 75.00 | 15-18
validator.js | 100.00 | 100.00 | 100.00 | 100.00 |
Here, calculator.js has gaps: only 50% branch coverage means some if/else paths weren't tested. Lines 15-18 show exactly where.
Identifying Untested Code Paths
The most valuable insight comes from uncovered lines and low branch coverage. If you see 50% Branch coverage, you likely have untested error handling, edge cases, or conditional logic. Open the detailed HTML report (if available) to see highlighted code—red backgrounds indicate untested lines.
What Good Coverage Looks Like
A 100% coverage number isn't automatically good (you could have meaningless tests), and 70% isn't automatically bad (critical paths might all be covered). Focus on which code is uncovered—untested error handlers are more concerning than unreachable fallback logic.
Key Takeaway: Coverage reports are diagnostic tools showing where tests are missing, not just how much is tested—use uncovered line numbers and branch percentages to find gaps in your test suite's exploration of your code's behavior.