Framework
vitest-dev/vitest avatar
vitest-dev/vitest

Vitest: A Vite-Native Test Runner for TypeScript and Component Code

Next generation testing framework powered by Vite.

17,174 stars2,055 forksTypeScriptMIT

At a glance

What is it?
Vitest reuses your Vite configuration to transform and run tests, offering Jest-compatible APIs, browser mode and v8 coverage. It is for teams already on Vite, and it is a poor fit for anyone pinned to an older Node or Vite release.
Who is it for?
Adopt Vitest if your application already builds with Vite 6.4 or newer and runs Node 22.12 or newer, because the test runner then inherits the same resolvers, transformers and plugins as your app. Do not adopt it if you are locked to an older Vite or Node line, or if your suite is deeply tied to Jest-specific configuration that the compatibility layer does not cover.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem Vitest solves for Vite projects

A Vite application already has a working pipeline: config file, resolver aliases, plugins, TypeScript and JSX transforms. A separate Jest setup usually needs its own copy of that pipeline, maintained by hand through transform and moduleNameMapper entries. When the two drift, tests pass against a module graph the application never builds. Vitest's stated purpose is to remove that second pipeline. The README lists "Vite's config, transformers, resolvers, and plugins" as the first feature, with the instruction to "use the same setup from your app".

The audience is therefore narrow and specific. Frontend and full-stack teams on Vite, writing TypeScript or JSX, who want assertions, snapshots, mocking, coverage and a watch loop from one dependency. The README also lists Vue, React, Svelte, Lit and Marko component examples, plus JSDOM and happy-dom for DOM mocking, so component testing is an intended use, not an afterthought. If your build tool is not Vite, the central selling point does not apply to you.

How Vitest reuses the Vite pipeline

The mechanism is that Vitest runs your code through Vite's transform and resolution stack rather than a bespoke one. Aliases, plugins and TypeScript settings that already work for the app apply to test files too. The README credits @pi0 for "the idea and implementation of using Vite to transform and bundle the server code", which is the architectural origin of this approach.

On top of that pipeline sit the test-facing pieces. Assertions come from Chai with Jest-compatible expect APIs, so existing expect calls mostly carry over. Snapshot testing follows the Jest snapshot format. Mocking, stubbing and spies are described as Jest-compatible. Coverage is native, through either v8 or istanbul. Watch mode is described as "smart & instant", and the project calls it "like HMR for tests". For component work there is Browser Mode, which the README says runs tests "in the browser natively", alongside JSDOM and happy-dom for lighter DOM emulation. Projects support lets one repository hold several test configurations, and sharding is listed for splitting a run across machines.

The runtime floor is explicit and worth reading twice: "Vitest requires Vite >=v6.4.0 and Node >=v22.12.0". The monorepo package.json tightens the Node range to ^22.12.0 || ^24.0.0 || >=26.0.0.

Installing Vitest and running a first test

The README's own quick start is a single command, npx vitest, which runs the local or fetched binary against your project. The package is published as vitest on npm. There is no separate init step documented in the README; configuration lives in a Vite config file, and the documentation site at vitest.dev/guide covers the details.

A minimal test file uses the named exports from vitest. The README gives this example:

ts
import { assert, describe, expect, it } from 'vitest'

describe('suite name', () => {
  it('foo', () => {
    expect(1 + 1).toEqual(2)
    expect(true).to.be.true
  })

  it('bar', () => {
    assert.equal(Math.sqrt(4), 2)
  })

  it('snapshot', () => {
    expect({ foo: 'bar' }).toMatchSnapshot()
  })
})

Then run the suite from the project root:

bash
npx vitest

The README shows no expected console output, so what you see on a first run depends on your own test files. What you should confirm is that the runner picks up files matching its default include patterns without any additional configuration, and that the snapshot assertion creates a snapshot file on first execution. If your project pins Vite below 6.4.0 or Node below 22.12.0, expect the run to fail before any test executes.

Where Vitest is the wrong tool

The version requirements are the sharpest limitation. Vite >=6.4.0 and Node >=22.12.0 are not soft recommendations; they are stated as requirements. A team on an older Node LTS, or on a Vite major that predates 6.4, cannot adopt Vitest without upgrading both. That upgrade cost is real and is not something the README discusses.

There is also a category error worth naming. Vitest is a unit and component test runner. The README lists Browser Mode and component examples, but it says nothing about end-to-end flows across a deployed application, network interception against a live server, or multi-page navigation. Teams searching for vitest vs playwright are usually asking the wrong question: Playwright drives a real browser against a running application, while Vitest's browser mode runs your test files and components inside a browser environment. They occupy different layers, and the README offers no guidance on combining them.

Finally, Jest compatibility is described but not quantified. The README says "Jest-compatible mocking, stubbing, and spies" and Jest expect compatible APIs. It does not enumerate what is missing. If your suite depends on Jest-specific behaviour beyond that description, the README is silent on whether it will work, and you should treat the migration as unverified until you run it.

Vitest against Jest and Playwright

The difference from Jest is architectural, not cosmetic. Jest owns its transform pipeline; Vitest borrows Vite's. In a Vite project that means one configuration to keep correct instead of two, and test code that resolves modules exactly the way the application does. The README explicitly credits the Jest team and community for the testing API, so the surface is deliberately familiar. The trade is that Vitest inherits Vite's constraints, including the Vite 6.4 floor, while Jest on its own does not require Vite at all. A project without Vite gains less from Vitest and takes on an extra dependency.

Playwright is a different comparison. It is not a test-runner alternative so much as a browser-automation layer. Vitest's browser mode, per the README, is for "running component tests in the browser", with framework examples for Vue, React, Svelte, Lit and Marko. That is component-level verification in a real browser environment. Playwright's territory is application-level journeys. A repository can reasonably use both, and the README does not present Vitest as a replacement for that kind of end-to-end coverage.

Maintenance, releases and the MIT licence

The repository is not archived, and the last push was on 2026-09-21. Releases are frequent: v5.0.0 on 2026-09-03, then v5.0.1 on 2026-09-15, with release candidates in between. The monorepo package.json reports version 5.0.1 and pins [email protected] as the package manager, which tells you the maintainers run the project as a pnpm workspace with packages under packages/ and integration suites under test/.

Upgrade cost is mostly a function of the Node and Vite floors. Because Vitest consumes Vite's config, a Vite major upgrade and a Vitest major upgrade tend to arrive together, and the release candidates for v5.0.0 suggest the project does staged majors rather than silent breaking changes. The README does not document a rollback procedure or a migration guide for major versions; the documentation site is where that material lives.

Licensing is MIT, stated in the README as "MIT License © 2021-Present VoidZero Inc. and Vitest contributors". MIT is permissive, and the practical implication for most teams is that you can use Vitest in commercial and closed-source projects without publishing your test code. This is a description of the licence text, not legal advice; if your organisation has specific obligations around attribution or vendored dependencies, route the question to whoever handles licensing.

Editorial conclusion

Adopt Vitest if your application already builds with Vite 6.4 or newer and runs Node 22.12 or newer, because the test runner then inherits the same resolvers, transformers and plugins as your app. Do not adopt it if you are locked to an older Vite or Node line, or if your suite is deeply tied to Jest-specific configuration that the compatibility layer does not cover. Before migrating, verify three things in your own repository: that npx vitest runs your existing test globs unchanged, that your mocking calls behave under vi.mock, and that your coverage thresholds still hold when switching from istanbul to the v8 provider.

Frequently asked questions

What is Vitest used for?

It is a testing framework that runs your tests through Vite's config, transformers, resolvers and plugins. The README lists assertions, snapshots, mocking, coverage, watch mode, browser mode and component testing as its features.

Why would I use Vitest instead of Jest?

The README's first listed feature is that Vitest reuses Vite's config, transformers, resolvers and plugins, so a Vite project keeps one pipeline instead of maintaining a separate Jest transform setup. It also credits the Jest team for the testing API, so the assertion and mocking surface is deliberately Jest-compatible.

What is the difference between Vite and Vitest?

Vite is the build and dev tool whose configuration Vitest consumes; Vitest is the test runner built on top of it. The README describes Vitest as a testing framework powered by Vite, and requires Vite >=v6.4.0 as a peer.

How do you install Vitest?

The package is published as vitest on npm, and the README's quick start is to run npx vitest in your project. The README does not document a separate init command, so configuration goes in your Vite config file.

How do you use Vitest with React?

The README lists React among the component-testing examples and points to a browser-examples repository for it, and it lists JSDOM and happy-dom for DOM and browser API mocking. It does not give a step-by-step React setup in the README itself; that lives in the documentation at vitest.dev.

How do you use Vitest coverage?

The README describes coverage as native, available through either the v8 or the istanbul provider. It does not show the configuration keys or the install command for either provider, so check the coverage page of the documentation before wiring it into CI.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. vitest-dev/vitest on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/vitest-dev-vitest.svg)](https://hysenlabs.com/projects/vitest-dev-vitest)