Repolode
vitest-dev

vitest-dev/vitest

A unit and component testing framework powered by Vite, reusing your Vite config, transformers and plugins for tests.

Open-source alternative to:Jest

Stars
17,271
Forks
2,095
Open issues
361
Last commit
2 hours ago

What is it?

Vitest is a JavaScript and TypeScript testing framework built on Vite. Tests run with the same config, transformers, resolvers and plugins as your application, so there is no separate test build setup to maintain. It provides a Jest-style API with built-in Chai assertions that are compatible with Jest's expect, along with snapshots, mocking, stubbing and spies.

The framework covers several testing styles. It supports watch mode that reruns only affected tests, native code coverage through v8 or istanbul, and DOM mocking via JSDOM or happy-dom. A Browser Mode runs component tests in a real browser, with examples for Vue, React, Svelte, Lit and Marko. Benchmarking uses Tinybench, and type-level tests use expect-type.

Vitest requires Vite 6.4.0 or later and Node 22.12.0 or later.

Key features

  • 01Reuses your Vite config, transformers and plugins for tests.
  • 02Jest-compatible expect API with built-in Chai assertions and snapshots.
  • 03Watch mode that reruns affected tests quickly.
  • 04Native code coverage via v8 or istanbul.
  • 05Browser Mode for component tests in a real browser.
  • 06Built-in benchmarking with Tinybench and type-level testing with expect-type.

Use cases

  • Unit testing a Vite-based frontend or Node.js TypeScript project.
  • Component testing for Vue, React, Svelte or Lit in a real browser.
  • Migrating a Jest test suite to a faster, Vite-native runner.
  • Measuring code coverage and running type-level assertions in CI.

Quick start

  1. 1

    Make sure Node.js v22.12.0 or newer is installed (Vitest also needs Vite v6.4.0 or newer)

  2. 2

    Run Vitest with npx

    npx vitest

Things to know

  • Requires Node.js v22.12.0 or newer and Vite v6.4.0 or newer.

In collections

Topics

FAQ

What is vitest?
A unit and component testing framework powered by Vite, reusing your Vite config, transformers and plugins for tests. Vitest is a JavaScript and TypeScript testing framework built on Vite. Tests run with the same config, transformers, resolvers and plugins as your application, so there is no separate test build setup to maintain. It provides a Jest-style API with built-in Chai assertions that are compatible with Jest's expect, along with snapshots, mocking, stubbing and spies.
Is vitest free to use? What license does it have?
vitest is open source under the MIT license. Check the license terms before using it in commercial products.
Is vitest still maintained?
Actively maintained. The last commit to vitest was on Oct 22, 2026.
What can I use vitest for?
Unit testing a Vite-based frontend or Node.js TypeScript project. Component testing for Vue, React, Svelte or Lit in a real browser. Migrating a Jest test suite to a faster, Vite-native runner. Measuring code coverage and running type-level assertions in CI.
How do I install vitest?
Make sure Node.js v22.12.0 or newer is installed (Vitest also needs Vite v6.4.0 or newer) Run Vitest with npx: npx vitest
Where can I get vitest?
The source code and installation instructions are on GitHub: https://github.com/vitest-dev/vitest

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects