🧪
Testing8M+/wkMIT

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
npm install -D vitest
yarn
yarn add -D vitest
pnpm
pnpm add -D vitest

Import

ESM
import { describe, it, expect } from 'vitest';

Quick Example

usage
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

Packagevitest
CategoryTesting
Weekly Downloads8M+
LicenseMIT
Installnpm install -D vitest

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.