testing.mdMarkdown, rendered
Testing TypeScript Code
Layered strategy
- Fast unit tests (Vitest)
- Integration tests for service boundaries
- Browser/e2e tests (Playwright) where user flows matter
- Type-level safety gate (
tsc --noEmit) in CI
Unit/integration baseline
- Use Vitest for TS-first fast feedback.
- Keep tests deterministic and isolated.
- Cover success and error paths.
Browser/e2e baseline
- Use Playwright for cross-browser flow validation.
- Favor locator-based assertions and built-in auto-wait behavior.
- Keep tests independent; avoid serial mode unless unavoidable.
- Use worker limits strategically in CI.
CI quality gates
npm run typechecknpm run lintnpm run test
Optional:
npm run test:e2efor Playwright suites
Sources
- Vitest guide: https://vitest.dev/guide/
- Playwright writing tests: https://playwright.dev/docs/writing-tests
- Playwright parallelism: https://playwright.dev/docs/test-parallel