What it is
Vitest is a unit testing framework for JavaScript and TypeScript, built on Vite. It reuses the project's Vite configuration, so tests understand the same imports, aliases and plugins as the app, with no separate build setup. That means the code under test is transformed exactly the way the app's own build transforms it, which removes a common source of surprises.
Its API is largely compatible with Jest, so describe, it, expect and mocks look familiar. It runs tests in watch mode that reruns only what changed, supports TypeScript and JSX without extra steps, and can report code coverage. It can also run tests in a simulated browser environment such as jsdom, which suits React component tests, and in parallel across worker threads.
How I use it
- Unit tests for Rental Pilot's React web app run in Vitest.
- Works beside Playwright end-to-end tests and the production smoke suite that runs after every deploy.
- Shares the web app's Vite setup, so tests and builds resolve code the same way.
Vitest is the right tool when an app is already built with Vite and you want unit tests that start fast and share its configuration. I reach for it because Rental Pilot's web app runs on Vite, so the tests and the app see the code the same way and there is one less config to keep in sync.
Questions
Vitest or Jest?
If the project already uses Vite, Vitest is usually simpler because it shares the same configuration. Its API is close to Jest's, so moving between them is not hard.
What does Vitest test in Rental Pilot?
The unit-level logic of the React web app. Whole user flows are covered separately by Playwright, and a smoke suite checks production after each deploy.