test-strategy
test-strategy
Test behaviour, not the design. Logic gets fast unit tests; the browser is kept for what only a browser can show. A suite that breaks on every design tweak or copy rewrite catches no bugs and teaches everyone to ignore red.
What goes where
Unit tests — for pure logic: validation schemas, ranking and sorting, dates and times (opening hours, time zones), calculations, formatting, parsing. Use the project's unit runner (Vitest for a Vite or TS project unless something else is already set up), with files beside the code as *.test.ts. If the logic is buried in a component, pull it out into a function and test that. Running logic like this through a browser is slow, flaky, and hard to cover edge cases with.
End-to-end tests (Playwright) — for user journeys and what only a real page shows:
- navigation and routing, forms end to end (submit, errors, success state)
- keyboard use and focus order, reduced motion, print styles
- layout problems a user would actually hit: content off screen, horizontal scroll, controls overlapping each other
No test — for design values: colours, border widths, font sizes, spacing, hover scale, transforms, icon sizes. Those belong in review. An assertion that a card is rgb(17, 24, 39) breaks on every palette tweak and has never caught a bug.