Vitest
The fast Vite-native unit test runner for JS, TS, React, Vue, Svelte, and Node. Setup, matchers, mocking, snapshots, coverage, browser mode, workspaces, type testing, and real-world testing patterns with MSW, hooks, stores, and CI.
FundamentalsTopics 1–9
- ·What is Vitest & why it exists
- ·Install & project setup
- ·Writing your first test
- ·describe / test / it structure
- ·expect matchers
- ·Running tests & watch mode
- ·The Vitest UI
- ·Basic mocking with vi.fn() and vi.spyOn()
- ·Configuring vitest.config.ts & TypeScript
Start Fundamentals →
IntermediateTopics 10–18
- ·Lifecycle hooks (beforeEach / afterEach / beforeAll / afterAll)
- ·vi.mock() for module mocking
- ·Faking timers with vi.useFakeTimers()
- ·Snapshot testing & inline snapshots
- ·Testing async code & promises
- ·Testing React with @testing-library/react
- ·Testing Vue with @vue/test-utils
- ·Coverage with @vitest/coverage-v8
- ·Globals vs explicit imports
Start Intermediate →
AdvancedTopics 19–27
- ·Vitest workspaces for monorepos
- ·Browser mode
- ·In-source testing
- ·Custom matchers via expect.extend
- ·Parallel & concurrent execution
- ·Isolation modes (threads vs forks)
- ·Benchmark testing with bench
- ·Type testing with expectTypeOf
- ·ESM vs CJS mocking & dependency injection
Start Advanced →
PatternsTopics 28–36
- ·Testing custom React hooks
- ·Testing a Zustand or Redux store
- ·API client testing with MSW
- ·Next.js server actions & route handlers
- ·Testing Node.js CLIs
- ·Fixture patterns & data builders
- ·Error boundaries & edge cases
- ·Integration testing with an in-memory database
- ·CI integration with GitHub Actions
Start Patterns →