February 22, 2026 1 min read
Four-Layer Testing Strategy: Unit to Production
Concept
Depth: ●●○○○
Unit → integration → edge case → E2E + migration tests with testcontainers. How I test a 256K-line codebase as a solo developer.
The Four Layers
Unit (Vitest): Zod validation, business logic, rate limiter. Integration: Full flow tests — booking lifecycle, payment flow, RLS enforcement. Edge cases: Gift-card double-spend simulation, DST transitions, midnight boundaries, currency rounding. E2E (Playwright): 21 specs with auth fixtures.
Migration Tests
testcontainers spins up real Postgres 15, applies all 52 migrations, verifies tables/indexes/constraints, confirms idempotency. Runs in CI on every push.