Vite-powered transforms
Tests use the same Vite config, plugins and aliases as the app, so TypeScript, JSX, Vue SFCs and Svelte components need no separate transpiler setup.
Vitest is a fast unit test runner built on Vite. It understands TypeScript, ESM and your existing Vite config out of the box, and ships Jest-compatible APIs, snapshots, mocking, coverage and a browser dashboard.
Vitest is an open-source testing framework that uses Vite to run your tests with the same plugins, import aliases and TypeScript settings as your application.
Write tests with familiar APIs such as describe, expect and vi.fn(). Watch mode reruns tests affected by the files you edit. For browser-specific behaviour, run your tests in a real browser or inspect results in Vitest UI.

Ten capabilities that matter day to day, from the transform pipeline to the browser dashboard.
Tests use the same Vite config, plugins and aliases as the app, so TypeScript, JSX, Vue SFCs and Svelte components need no separate transpiler setup.
Vitest tracks the module graph and reruns only the test files that import the changed module, keeping feedback tight while you edit.
describe, it, expect, vi.fn, vi.mock, fake timers and snapshots follow familiar names, which makes most Jest suites portable with small edits.
Vitest 5 adds vi.when for per-argument spy behaviour, plus toHaveBeenExhausted to assert that every planned response was used.
Choose the v8 provider or Istanbul, enforce global or per-file thresholds and export text, HTML, JSON or lcov reports from one flag.
Run component tests in a real browser via Playwright or WebdriverIO. Trace View records interactions and assertions as DOM snapshots you can replay.
The optional @vitest/ui package opens a browser dashboard to filter suites, rerun files, inspect console output and browse the module graph.
Define multiple projects in one config, each with its own environment. Inline projects inherit the root config, and the -p filter respects nesting.
bench is a test-context fixture in Vitest 5, with baseline comparison, and --repeats runs a test several times to expose flaky behaviour.
Inline, file and custom-serialiser snapshots are built in, and import.meta.vitest lets small utilities keep their tests next to the implementation.
Install Vitest, write a test and run it locally or in CI.
vitestRun npm install -D vitest in a project that has Node.js 22.12 or newer. Vite is installed as a peer dependency when it is not already present.
Add a test block to vite.config.ts or create vitest.config.ts to set the environment, globals, setup files, coverage and projects.
Create sum.test.ts, import test and expect from vitest, and assert the behaviour of your function or component.
Start npx vitest for watch mode or vitest run for a single pass. Add --ui or --coverage when you need them.
Requirements below come from the Vitest 5 release notes and the package manifest on the main branch. Nothing here is estimated.
22.12+, 24.x, 26+
Required6.4, 7.x or 8.x
Peer dependencyWindows, macOS, Linux
Wherever Node runsPlaywright, WebdriverIO, preview
Optional providernpm, pnpm, yarn, bun
Any of themVue, React, Svelte, Solid, Angular, Next.js
Via Vite plugins or buildersjsdom, happy-dom
Install separatelyTypeScript, JavaScript, JSX/TSX, ESM, CJS
Built in| Major | Released | Minimum Node.js | Vite range | Status |
|---|---|---|---|---|
| Vitest 5 | September 3, 2026 | 22.12 | 6.4 – 8.x | Current major |
| Vitest 4 | October 22, 2025 (4.1 on March 12, 2026) | 20.x | 6 – 7.x (4.1 adds Vite 8) | Previous major, latest minor receives fixes |
| Vitest 3 | January 17, 2025 | 18.x | 5 – 6.x | No longer supported |
Typical scenarios the runner is designed for.
Pure functions, parsers, validators and stores get instant feedback in watch mode with no DOM overhead.
Render Vue, React, Svelte or Solid components in jsdom or a real browser and assert on the DOM with Testing Library.
Use projects to give each package its own environment and setup while sharing one root config and one command.
Spin up handlers, mock fetch with vi.mock or MSW, and test routes alongside the code that defines them.
vitest run with the junit or json reporter, coverage thresholds and --merge-reports fits GitHub Actions, GitLab CI and others.
The bench fixture compares implementations and stores baselines so regressions show up in the same run as the tests.
Vitest is not only about raw speed. Its value is removing an entire second toolchain from the project and giving every failure a place where it can be understood.
Download NowAliases, env variables and plugins defined for the app apply to tests automatically.
Module-graph-aware reruns mean a save usually triggers only a handful of test files.
Jest-style APIs keep existing knowledge and most existing tests useful.
Type-check mode, typed fixtures and expectTypeOf make types part of the test suite.
UI dashboard, HTML reporter and Trace View turn failures into something you can inspect.
Framework docs for Angular, Next.js, Nuxt, SvelteKit and others document a Vitest path.
Pick the route that matches your project. Each one ends with a passing test.
npm install -D vitest (or pnpm add -D vitest, yarn add -D vitest, bun add -d vitest).
In package.json set "test": "vitest". CI pipelines should call vitest run instead.
Create src/sum.test.ts importing test and expect from vitest.
Execute npm test. Watch mode starts, reruns on save and prints pass/fail per file.
Add vitest as a dev dependency next to the vite version already in the project.
Add /// <reference types="vitest/config" /> and a test: { environment: 'jsdom' } block if components need a DOM.
Install jsdom or happy-dom and, for components, @testing-library/* for your framework.
npx vitest picks up the existing plugins and aliases; no second config file is required.
Use the Download button below to fetch the main-branch archive from GitHub and extract it.
The monorepo uses pnpm. Enable it with corepack enable or install it globally, then run pnpm install.
Run pnpm build from the repository root to produce the dist output of every package.
Link a package into a test project or run the repository's own test suite with pnpm test.

The button fetches main.zip straight from the official GitHub repository: the complete Vitest monorepo including the core package, UI, browser mode, coverage providers, docs and examples. It is source code, not an installer. To add Vitest to a project, use the npm command from the setup section; use this archive to read, build or contribute to the code.
Download VitestPractical guidance, not marketing claims.
The link above goes to github.com/vitest-dev. Avoid re-packaged downloads from unknown sites; the package on npm is the normal install path.
Run npm ls vitest to confirm the version and npm audit to review advisories in your dependency tree.
Tests run with your user's rights. Keep file-system and network side effects inside temporary folders and mocked clients.
Commit __snapshots__ and the config file so a bad update can be rolled back with your version control.
Patch releases ship frequently. Read the migration guide before moving between majors, especially from 4 to 5.
Strengths and the limitations you should know before adopting it.
Six issues that account for most first-week questions.
npm reports EBADENGINE or Vitest exits immediately. Update to Node.js 22.12 or newer; check with node -v and use nvm or fnm to switch.
ERESOLVE during install usually means an old Vite pin. Vitest 5 wants Vite 6.4+; update Vite or install the Vitest major that matches your Vite.
The default environment is Node. Install jsdom or happy-dom and set test.environment, or add a @vitest-environment comment to the file.
Plain vitest is watch mode. Use vitest run in CI, and close open handles such as servers and timers in afterAll.
Vitest 5 clears mock history before each test. Assert within the test that made the calls, or set clearMocks: false to keep the old behaviour.
Restart the watcher after editing vite.config or vitest.config. If the on-disk module cache looks stale, clear the .vitest directory and rerun.
Twenty answers in two groups. Open one at a time.
It links to the official GitHub archive of the Vitest repository's main branch (main.zip). That is the full source code of the project, not an installer. To use Vitest in a project you normally run npm install -D vitest instead.
Run npm install -D vitest (or the pnpm, yarn or bun equivalent), add "test": "vitest" to the scripts section of package.json, create a file ending in .test.ts or .spec.js, and run npm test.
Vitest 5 requires Node.js 22.12 or newer; the package also lists 24.x and 26+ as supported. Older Node releases are not supported by the current major, so update Node first if the install or run step fails.
Vite is a required peer dependency. Vitest 5 works with Vite 6.4, 7 and 8. In a Vite project it is already present; in a plain Node project, npm installs it alongside Vitest automatically in most setups, or you can add it explicitly.
Yes. Vitest is published under the MIT license by the vitest-dev organisation on GitHub. There are no paid tiers, licence keys or usage limits.
Vitest runs wherever a supported Node.js version runs, which includes Windows, macOS and Linux. Browser Mode additionally needs a browser provider such as Playwright, WebdriverIO or the preview provider.
Recent Angular CLI versions ship Vitest as the default unit-test runner through the @angular/build:unit-test builder. Existing Karma projects can switch by changing the test builder in angular.json. The AnalogJS vitest-angular builder is a community alternative.
Install vitest, @vitejs/plugin-react, jsdom, @testing-library/react and @testing-library/dom as dev dependencies, create vitest.config.mts with the React plugin and the jsdom environment, and add a test script. Next.js also publishes a with-vitest starter example.
Vitest UI is the optional @vitest/ui package that adds a browser dashboard for your test run. Install it, then start Vitest with npx vitest --ui; the dashboard opens in your browser and updates as files change.
Yes. Extract it, install pnpm, run the install and build commands from the repository's contributing guide, and the packages are built into their dist folders. This is useful for contributing or reading the code, not for day-to-day testing.
Vitest intentionally mirrors most of the Jest API: describe, it, expect, mocks and snapshots look familiar. Many suites move with small changes, but mocking details, environment setup and some matchers differ, so run the suite and fix differences file by file.
Vitest 5 (September 2026) raised the minimum to Node 22.12 and Vite 6.4, turned clearMocks on by default, made unawaited async assertions fail, moved bench into the test context, made browser locators strict and placed reporter output in a single .vitest directory.
By default tests run in a Node environment. For DOM tests install jsdom or happy-dom and set test.environment in your config, or add a // @vitest-environment jsdom comment at the top of the file.
Running vitest with no arguments starts watch mode on purpose. Use vitest run for a single pass, which is what CI pipelines should call.
Pass a path filter such as npx vitest run src/utils, use -t "name" to match test titles, or temporarily mark a test with .only. Vitest UI also lets you click a single file to rerun it.
Install @vitest/coverage-v8 (or @vitest/coverage-istanbul) and run npx vitest run --coverage. Thresholds, include and exclude patterns and reporters are set under test.coverage in the config.
Yes, through Browser Mode. It runs test files inside a real browser using a provider such as Playwright or WebdriverIO, and Vitest 5 adds a Trace View that replays interactions and assertions as DOM snapshots.
clearMocks now defaults to true, so call history is cleared before every test. If your suite relied on counts accumulating across tests, either restructure the tests or set clearMocks: false in the config.
Yes. Because Vitest uses Vite's transform pipeline, TypeScript, JSX, ESM and most framework plugins work without a separate transpiler configuration.
The logo lives in the official repository and is part of the project's brand. Use it to refer to the project, for example in a tooling badge or blog post, and do not present it as your own product branding or imply endorsement.