Testing Tech
How do you trust that your code works — and keeps working?
The Testing Trophy defines the strategy. These are the tools that implement each layer.
L3 E2E → Playwright
L2 Browser → Vitest Browser Mode + MSW
L2 Integration → Vitest (target) / Jest (current) + real DB or mocked composition root
L1 Unit → Vitest (target) / Jest (current)
L0 Static → tsc --noEmit
Dig Deeper
- Vitest — Primary test runner: L1 unit, L2 integration, L2 browser mode. Nx setup, file naming conventions, MSW integration
- Jest — Current runner in the monorepo. Migration path to Vitest documented. Configuration, isolation, CI checklists
- React Testing Library — Component testing that mirrors how users interact with UI. Used within Vitest Browser Mode
- MSW — Mock Service Worker: shared mocking language across L1, L2, and browser tests. Handlers defined once, used everywhere
E2E
Playwright handles L3 E2E tests. Feature specs using Page Object Model, not function specs. Browser-dependent flows only — form wiring, auth redirects, responsive layout.
Smart Contracts
Smart contract testing is a separate domain with different tools and economics.
Security Audit is vital — fast, best practice contract testing is extremely valuable.
Tool Selection
| Layer | Primary Tool | Role | Nx Target |
|---|---|---|---|
| L0 Static | TypeScript compiler | Type checking | typecheck |
| L1 Unit | Vitest / Jest | Schema + pure function tests | test-schema |
| L2 Integration | Vitest / Jest | Server action + DB tests | test-integration |
| L2 Browser | Vitest Browser Mode | Client component tests in real Chromium | test-integration |
| L2 Mocking | MSW | Shared network request interception | (used within L1/L2) |
| L3 E2E | Playwright | Browser-dependent user journeys | e2e |
Context
- Testing Platform — Trophy strategy, economics, Story Contract connection
- Testing Strategy — Layer model, selection rules, recovery backlog
Questions
What does your test suite prove — that the code works, or that the mocks work?
- Which of your "passing" tests would still pass if you replaced every API call with a stub returning empty arrays?
- If integration tests are the only ones that catch wiring bugs, why do most projects write unit tests first?
- What's the cost of a false green — a test suite that passes while production breaks?