Careeroza
Testing Strategy
What to Test Where
| Layer | Tool | Examples |
|---|---|---|
Pure logic (lib/) | Vitest or Jest | Price formatting, cart totals, filter parsing, permission checks |
| Client Components | React Testing Library + Vitest/Jest (jsdom) | AddToCartButton, forms, filters |
| Route handlers / actions | Vitest with mocked data layer | Status codes, validation errors |
| Full flows incl. async Server Components | Playwright | Search → product → cart → checkout |
Note: Async Server Components are not yet well supported by unit test tools. Test their logic in lib/ and the rendered result with Playwright.
The Pyramid
▲ few Playwright E2E (slow, real browser)
▲▲▲ Component tests (RTL)
▲▲▲▲▲▲▲ many Unit tests for lib/ (fast)