Skip to main content

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

LayerPrimary ToolRoleNx Target
L0 StaticTypeScript compilerType checkingtypecheck
L1 UnitVitest / JestSchema + pure function teststest-schema
L2 IntegrationVitest / JestServer action + DB teststest-integration
L2 BrowserVitest Browser ModeClient component tests in real Chromiumtest-integration
L2 MockingMSWShared network request interception(used within L1/L2)
L3 E2EPlaywrightBrowser-dependent user journeyse2e

Context

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?