
When the build runs on Vite, testing follows its own logic: the same config, the same transforms, the same aliases. What that implies, where Vitest departs from Jest habits, and what Browser Mode gives you once jsdom stops resembling a browser.
Vitest is often chosen for speed and for speaking the project's own language: the same Vite config, the same plugins, the same transform for TypeScript, JSX and aliases. But a fast run does not make tests reliable. The suite grows, some tests fail every other time, they hold more mocks than behavior under test, and the green check becomes a ritual. A professional test is an assertion about the system's observable behavior that fails for a reason and explains exactly what broke.
This book takes Vitest apart from install to a durable suite. First - the foundation: installation without magic, an explainable Vite config, the first test and what is even worth testing, TypeScript and ESM natively, structure and precise matchers. Then - discipline: a clean world per test, honest asynchrony, mock functions, spies, the module- and network-mock boundaries, deterministic clocks. Next - environments and data: React and custom hooks, Next.js, a backend with real boundaries, snapshots, coverage, type testing, benchmarks and in-source tests. After that - scale: Test Projects, pools and Browser Mode, the Vitest UI and debugging, durability patterns, flakiness and performance, CI and migrations.
The material rests on one principle: understand the mechanism instead of memorizing recipes. Where the usual advice is a technique, this book explains why it works, what it costs and when it stops being the right call. Behavior and APIs are checked against the Vitest 4 and Testing Library documentation, not against common retellings.
You can read in order - the chapters run from install to discipline, environments and operating the suite - or go straight to the one you need. At the end there is a short glossary of terms and a list of primary sources.