
Your Tests Are Passing. That Doesn't Mean They're Good
I've worked on projects with 85% test coverage where bugs still made it to production every week. The team would look at the coverage report, see green, and feel safe. But the tests were lying. Here's what was actually happening: test('should process user data', async () => { const result = await processUser(mockData); expect(result).toBeTruthy(); }); This test "covers" the processUser function. Coverage goes up. CI is green. But what does it actually prove? That the function returns something that isn't null, undefined, 0, or false. That's it. The function could return completely wrong data and this test would still pass. Or this one — common in E2E tests: test('user signup flow', async ({ page }) => { await page.goto('/signup'); await page.fill('#email', 'test@test.com'); await page.fill('#password', '12345678'); await page.click('button[type="submit"]'); await page.waitForURL('/dashboard'); }); It walks through the whole signup flow but never checks if the user was actually created,
Continue reading on Dev.to Webdev
Opens in a new tab



