Skip to content

Testing Strategy v1

Three layers: Vitest (unit, jsdom), Playwright (E2E, browser matrix), Lighthouse (perf + a11y). Coverage ≥ 90% global, 100% on every compiler Pass. Visual regression runs only on chrome-desktop because cross-OS font rendering produces false positives elsewhere.

Unit (Vitest)

sh
just tu  # fast unit
just tc  # full + coverage
  • Environment: jsdom.
  • Setup: tests/setup.ts mocks Shiki highlighter, WebGPU APIs, localStorage, ResizeObserver, IntersectionObserver.
  • Coverage provider: v8.
  • Fast mode (VITEST_FAST=true) skips slow UI specs:
    • src/routes/**/*.svelte.test.ts
    • src/shared/ui/**/*.test.ts
    • src/widgets/**/ui/*.test.ts
    • src/features/background/ui/*.test.ts
    • src/widgets/search/ui/*.test.ts
  • Coverage exclusions: test files, .d.ts, index.ts re-exports, app shell, data/interface files.

Integration / E2E (Playwright)

sh
just ti           # local Playwright
just bs           # update snapshots (current OS)
just baseline ci  # update snapshots in Docker (Linux parity)
  • Local config: playwright.config.ts — chrome-desktop only, webServer via bun run serve:playwright.
  • CI config: playwright.ci.config.ts — matrix: chrome-desktop, chrome-mobile, firefox-desktop, firefox-mobile.
  • Spec dependencies: tests/e2e/homepage.spec.ts runs first per browser; other specs depend on it.
  • Visual regression: chrome-desktop only (tests/e2e/post-ux.spec.ts).
  • A11y: @axe-core/playwright assertions in tests/e2e/a11y.spec.ts.

Lighthouse

sh
just test lhci
  • Config: .lighthouserc.json.
  • URLs: /, /blog/, /about/.
  • Asserts: performance ≥ 0.9, accessibility ≥ 0.9, SEO ≥ 0.9, best-practices ≥ 0.9.
  • Skips: PWA, HTTPS, and legacy JS audits.

Test Commands

WhatFull commandShortcut
Fast unit testsjust test unitjust tu
Unit + coveragejust test coveragejust tc
Playwright localjust test integrationjust ti
All testsjust test alljust ta
Lighthouse CIjust test lhci
Bundle budgetjust test bundle
Update snapshots (local OS)just baseline snapshotsjust bs
Update snapshots (CI parity)just baseline ci
Update bundle baselinejust baseline bundlejust bb

Agents should use shortcuts to save tokens. Humans can use full commands for clarity.

Test Rules

  • No code merges without a corresponding test file.
  • Mocks only at system boundaries (WebGPU, fetch, localStorage). Never mock internal modules.
  • Compiler Passes require 100% coverage — non-negotiable.
  • Visual snapshots committed only after manual diff inspection of the failure artifact.

Where things live

KindPath
Vitest setuptests/setup.ts
Vitest configvite.config.ts (vitest section)
Playwright local configplaywright.config.ts
Playwright CI configplaywright.ci.config.ts
Playwright specstests/e2e/*.spec.ts
Lighthouse config.lighthouserc.json
Lighthouse runnerscripts/run-lhci.mjs
Bundle reportscripts/bundle-report.mjs
Coverage outputtarget/coverage/
Playwright reporttarget/playwright-report/

When something breaks

Troubleshooting → Snapshot mismatch.