Testing Strategy

What to Test Where

LayerToolExamples
Pure logic (lib/)Vitest or JestPrice formatting, cart totals, filter parsing, permission checks
Client ComponentsReact Testing Library + Vitest/Jest (jsdom)AddToCartButton, forms, filters
Route handlers / actionsVitest with mocked data layerStatus codes, validation errors
Full flows incl. async Server ComponentsPlaywrightSearch → 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)