vitest
Vitest is a blazing-fast unit testing framework powered by Vite, designed as a modern alternative to Jest with native ESM support, TypeScript support, and Vite'…
Installation
npm install -D vitest
yarn add -D vitest
pnpm add -D vitest
Import
import { describe, it, expect } from 'vitest';Quick Example
import { describe, it, expect } from 'vitest';
describe('math', () => {
it('adds numbers correctly', () => {
expect(1 + 2).toBe(3);
});
it('handles async', async () => {
const data = await fetchData();
expect(data).toBeDefined();
});
});About vitest
Vitest is a blazing-fast unit testing framework powered by Vite, designed as a modern alternative to Jest with native ESM support, TypeScript support, and Vite's instant hot module replacement. Vitest reuses Vite's transformation pipeline, meaning your tests use the same configuration as your application — no separate compilation step, no duplicate config. The framework is API-compatible with Jest, providing describe, it, expect, vi.fn() for mocking, vi.spyOn for spying, and vi.mock for module mocking, making migration from Jest straightforward. Vitest runs tests with native ES module support, handles TypeScript and JSX without configuration, supports multi-threaded execution via workers, and provides an interactive UI mode for browsing and debugging tests visually. The framework includes built-in code coverage through Istanbul or V8, snapshot testing, concurrent test execution, in-source testing (tests inside your source files), and benchmark support. Vitest's watch mode is nearly instantaneous because it leverages Vite's module graph to determine which tests are affected by file changes. It has rapidly become the preferred testing framework for Vite-based projects and modern JavaScript development.
Quick Facts
| Package | vitest |
| Category | Testing |
| Weekly Downloads | 8M+ |
| License | MIT |
| Install | npm install -D vitest |
Related Packages
Jest is a delightful JavaScript testing framework with a focus on simplicity, created by Facebook. I…
Vite is a next-generation frontend build tool created by Evan You (creator of Vue.js) that provides …
Testing Library is a family of packages that helps you test UI components in a way that resembles ho…
Mock Service Worker (MSW) is an API mocking library that uses the Service Worker API to intercept re…
Sinon.js provides standalone test spies, stubs, and mocks for JavaScript that work with any test fra…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.