JavaScript › Debugging, Testing & Tooling
What is code coverage and why isn't 100% coverage the same as bug-free code?
IntermediateAnswer
Code coverage measures which lines/branches of code ran during tests, expressed as a percentage. High coverage only proves code was *executed*, not that its behavior was *correctly asserted* — a test can run every line and still assert nothing meaningful.
// A test that runs the code but checks nothing:
test('runs without checking', () => {
calculateTotal(items); // 100% line coverage, zero verification
});Real-world example A team hitting 100% coverage but still shipping bugs because tests lacked real assertions.