In plain words
Code coverage is the share of your lines and branches that ran at least once during the tests, which points at untested code but says nothing about whether the checks are any good.
Where you see it
Running npx vitest run --coverage prints a table with a row per file and columns for statements, branches, functions and lines. Harbor's invoice.ts shows 91% of lines but 58% of branches: the discount and credit paths rarely run.
What goes wrong
- Chasing a number
Ask the agent for 100% and it may write tests that call every function and check nothing. Coverage goes up and protection doesn't.
test("covers refund", () => { refund(invoice); }); - Reading lines and ignoring branches
An if with no else counts as fully covered lines even when the false case never runs. Branch coverage shows which side of each decision was never taken.
- Treating covered as correct
A line can run in a test whose assertion is wrong or missing. Coverage finds untested code; only reading the tests tells you whether they're good.
What to tell your agent
Quick check
Sign in to earn +10 XP for itHarbor's coverage report shows invoice.ts at 100% of lines. What can you conclude?