Coverage Metric
Question
What does code coverage measure?
Hint
Coverage is necessary but not sufficient for quality.
Explanation
Code coverage measures what percentage of code is executed by tests. Types: 1) Line coverage — percentage of statements executed. 2) Branch coverage — percentage of conditional branches taken (if/else, switch). 3) Function coverage — percentage of functions called. 4) Statement coverage — similar to line. Tools: Jest (--coverage), Istanbul, c8. Coverage targets (e.g., 80%) ensure most code is tested. However, 100% coverage does not mean tests are good — they might not assert correct behavior. Coverage identifies untested code but does not measure test quality. Use coverage as a guide, not a goal. High coverage with weak assertions gives false confidence.
Related Resources
Related Lessons
- Coverage
Learn coverage.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.