Skip to Content
Docs12 Vitest

Vitest (unit + integration testing)

Vitest is our default test runner for unit and lightweight integration tests.

What to test (rule of thumb)

  • Unit tests: pure logic (formatters, validators, mapping functions).
  • Integration tests: a small slice of components + their dependencies (mock boundaries, not internals).
  • Don’t use unit tests to “prove the framework works”.

Sources

If we use React Testing Library in the app, also:

Standard approach (what we’ll converge on)

  • Test behavior over implementation details.
  • Mock at the boundary:
    • mock tRPC client calls in UI tests
    • mock microservice/data layer in procedure tests
  • Prefer factories for test data (typed helpers).

Exercises

  • content/exercises/05-typescript/01-refactor-js-to-ts-with-tests.mdx
  • content/exercises/06-vitest/01-component-and-boundary-tests.mdx
Last updated on