0

E2E with Playwright

Testingused in ~72% of apps

Unit tests pass, the build is green, and the deploy ships a checkout that silently 500s on a Stripe redirect. End-to-end tests are the only kind that drive a real browser through your real app — the difference between "the function returns the right value" and "a human can actually pay you."

Core idea. Playwright launches a real browser, navigates your running Next.js app like a user, and asserts on what actually renders. It auto-waits for elements and network, so async Server Components, auth sessions, and Stripe redirects all resolve before your assertions run — no manual sleeps. You don't test every path; you protect a small golden suite over the revenue-critical ones.
Playground, this isn't a screenshot
integration test — one flow, many components, network mocked
<Feed /> — the feature under test
#1First post on Pulse

Try it by hand: type, press Post. The test below drives this exact flow — no internals poked.

test runner — Vitest + Testing Library
Mount the whole feature
User types a post
User clicks Post
MSW intercepts the network call
Assert the list updated
the testing trophy — write tests, not too many, mostly integration
E2Efew · slow · most confidence
Integrationthe sweet spot — best ROI
Unitmany · fast · low confidence
Static (types + lint)free — TypeScript / ESLint

Integration tests render several components together and mock only the network — the best confidence-per-effort, so favor them.

↑ play a little first, then dig in