Mistake: Chasing 100% Coverage
Question
What is wrong with this testing strategy?
Code
// Goal: 100% code coverage
// Adding tests just to cover lines
test('covers line 42', () => {
render(); // no assertions, just calls the function
});
Hint
Coverage without assertions is meaningless.
Explanation
The mistake is chasing 100% coverage by adding tests with no meaningful assertions. A test that just calls a function to 'cover' it provides no value — it doesn't verify behavior. The fix: focus on testing behavior and edge cases with meaningful assertions. Let coverage be a byproduct of good testing, not the goal itself.
Related Resources
Related Lessons
- Test Coverage
Measuring and interpreting 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.