Testing strategy and quality gates
Eight steps to lock down regressions with vitest, pytest, Playwright, testcontainers, and the repository's manual CI runner, then prove completion and recovery.
- Difficulty
- Intermediate
- Lessons
- 8
More tests do not equal safer. Absent tests do not equal faster. The real design choice is which layers to emphasise for your project size, team, and cost of an incident.
Who it's for
- People endlessly stuck on "which test do I write here?"
- Folks running vitest, pytest, and Playwright in one repo
- Teams who want the CI green light to actually mean something
What you can do afterwards
- Apply the test pyramid (80% unit · 15% integration · 5% E2E) in practice
- Standardise vitest mocks with
vi.hoisted - Use pytest fixtures and parametrize well
- Run real PostgreSQL in tests with testcontainers
- Auto-generate Playwright smoke manifests
- Use the repository's manual CI runner and service-scoped quality gates
- Map completion evidence across product, design, engineering, user, and operations
- Put partial failure, migrations, readiness, and rollback into the quality gate
Flow
Building confidence through verification
Check small contracts quickly with the test pyramid and language-level unit tests.
Prove boundary behavior with container-based integration tests and focused E2E checks.
Make CI reproduce the same evidence and stop failures before deployment.
Accept completion only after public smoke and recovery exercises pass.
Cost and confidence rise from top to bottom. CI lands last because the gate only makes sense once every layer below is in place.
Steps
- Test pyramid · trade-offs — cost vs confidence · picking layers
- vitest basics + mock patterns —
vi.hoisted·vi.stubEnv· node vs jsdom - pytest · fixture · parametrize — conftest · async · coverage
- testcontainers — real PostgreSQL containers + idempotent seeding
- Playwright E2E — auto manifests ·
@writePROD skip - Manual CI runner and quality gate — OS wrappers · Node SSOT · artifacts · service scope
- Turn completion criteria into verifiable evidence — five perspectives · contracts · usability
- Put partial failure and recovery into the quality gate — idempotent seeds · expand/contract migrations · readiness · rollback
Prerequisites — getting-started + any prior test writing experience.