Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Vitest

Automatic tests for JavaScript and TypeScript apps.

TestingNPM

GitHubWebsite

1. License

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”

MIT allows use in paid and closed-source projects.

github.com/vitest-dev/vitest/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What Vitest does

Vitest is a free tool that runs automatic tests for JavaScript and TypeScript code. You or your AI assistant write small checks such as "adding 1 and 2 gives 3", and Vitest runs them again on every change and shows what broke. It fits projects built with Vite and reads the same settings.

What people build with it

Check that your functions still work

Write a few small checks for prices, dates or form rules; every change reruns them and a red line shows what broke.

Keep AI-written code honest

Ask your assistant to add tests with each change, then review them; the guide explains what good prompts and good tests look like.

Test page parts without a browser

Check that a form or button component renders and reacts, using a simulated page that runs fast in the terminal.

Test in a real browser

For parts that depend on real layout or browser behaviour, run the same tests inside Chromium through Playwright.

See which code no test touches

A coverage report lists the lines your tests never ran, so you know where a bug could hide.

Move an old Jest project over

Existing Jest tests mostly keep working, so a project can switch runners with a few small edits.

Vitest popularity

86 / 100
Gid Score, #30 overall
194M
downloads a week, npm
17.4K
GitHub stars
1,312
agent projects use it
Vitest: downloads per weeknpm, vitest 193,983,069
Vitest: GitHub starsvitest-dev/vitest 17,433

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Vitest is used

  • Vitest is a dependency in 1,312 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (27.0% of the 4,867 JavaScript/TypeScript ones), #1 of 122 in testing.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 3,365; those are left out of every share on this page.
  • The most used alternative in our scan is Jest (396 projects).
  • Projects that use it most often also use jsdom (41.4%), TypeScript (93.7%), Vite (50.5%).
  • It is more common in projects set up for OpenAI Codex (31.1%) than for Cursor (20.3%).

By coding agent

854 projects, 26.1%
620 projects, 20.4%
495 projects, 20.3%
146 projects, 30.8%
146 projects, 31.1%
96 projects, 28.7%
95 projects, 27.7%
60 projects, 21.5%

Often used with

In 41.4% of its projects
In 93.7% of its projects
In 50.5% of its projects
In 36.1% of its projects
In 63.0% of its projects
In 41.9% of its projects
In 37.4% of its projects
In 48.1% of its projects

Vitest in practice

Strengths

Your Vite config is your test config

Vitest reads <code>vite.config.*</code> by default, so existing Vite plugins and settings apply to tests with no extra setup. A separate <code>vitest.config.*</code> is optional and holds only test-specific settings.

Built to stand in for Jest

The docs say the API is compatible enough to serve as "a drop-in replacement in most projects." Mocking, snapshots and coverage come included.

Watch mode modeled on HMR

The site says watch mode reruns only the tests related to a change, "just like HMR for tests."

Tests in a real browser, not only a fake DOM

Browser Mode runs tests natively in a browser. The maintainers write that they built it to get "more accurate and reliable test results" than simulated environments give.

Watch out for

Recent Vite and Node only

The current docs state that Vitest requires Vite <code>&gt;=v6.4.0</code> and Node <code>&gt;=v22.12.0</code>.

Browser Mode is not an E2E runner

The docs call Browser Mode "Not a Drop-In Replacement" for standalone end-to-end runners. They recommend adding WebdriverIO, Cypress or Playwright.

Browser Mode is slower to start

A provider and a browser must start before any test runs. The docs warn this can mean longer initialization than other testing patterns.

A suite mixing expect, Chai assert and snapshots

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()
  })
})

More about Vitest

Funding
  • GitHub Sponsors: https://github.com/vitest-dev
  • Open Collective: https://opencollective.com/vitest
  • 19 GitHub sponsors

See all

Agent Skills for it
  • vitest: Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or worki
  • vitest: Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or worki

See all

Head to head
Packages around it
  • @vitest/coverage-v8: V8 coverage provider
  • @vitest/ui: Vitest UI
  • @vitest/browser-playwright: Browser Mode via Playwright
  • @vitest/browser: Browser Mode
  • @vitest/eslint-plugin: ESLint rules for Vitest
  • @vitest/coverage-istanbul: Istanbul coverage provider
More in Testing

Alternatives

Vitest This page

MITGid 86194M/wk

Jest

Pick Jest when an existing project already runs on it and you do not want to switch.

MITGid 8663.2M/wk

Playwright (JavaScript)

Pick Playwright Test for end-to-end tests that click through the whole app in several browsers.

pytest

Pick pytest when the code under test is Python.

Nx Jest Plugin

Nx plugin providing Jest testing capabilities and executors for monorepo projects.

MITGid 664.5M/wk

Compare Vitest with another tool

Get started

Tell your AI assistant

“Add vitest 5.1.0 (Node.js 22.12+, Vite 6.4+) with a "test" script, import test and expect from 'vitest' in every test file, keep vi.mock calls at the top level, await every .resolves or .rejects assertion, and run npx vitest run before you finish.”

  1. Add Vitest to the project as a development tool (it needs Node.js 22.12 or newer and Vite 6.4 or newer).

    npm install -D vitest

    From vitest.dev/guide/

  2. Add a test script to package.json and run it.

    {
      "scripts": {
        "test": "vitest"
      }
    }
    

    From vitest.dev/guide/

  3. In CI or for one-off checks, run once instead of watching.

    npx vitest run

    From vitest.dev/guide/

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Vitest
- Install as a dev dependency (`npm install -D vitest`). Check that the project has Vite >=v6.4.0 and Node >=v22.12.0.
- Name test files with `.test.` or `.spec.` in the file name. By default, other files are not picked up as tests.
- Put test settings in the existing `vite.config.*`. Create a separate `vitest.config.*` only for test-specific settings.
- Use `vitest run` to run tests once without watching. Plain `vitest` runs in watch mode, which is the default.
- Import test APIs explicitly, for example `import { describe, expect, it } from 'vitest'`.
- Add `.vitest/` to `.gitignore`, because Vitest and its integrations store generated artifacts there.
- On Bun, run tests with `bun run test`, never `bun test`.

Mistakes to avoid

Calling describe, it and expect without importing them (Jest habit)
import { describe, it, expect, vi } from 'vitest' in each file, or set test.globals: true in the config

Vitest does not turn global test functions on by default.

vi.mock('./calculator') inside a describe or test callback
Put vi.mock at the top level of the file (or use vi.doMock where it must run in place)

vi.mock is hoisted to the top of the file; since 5.0 a nested call throws instead of warning.

expect(promise).resolves.toBe(1) without await
await expect(promise).resolves.toBe(1)

Since 5.0 an unawaited async assertion fails the test instead of printing a warning.

Expecting a mock to keep calls recorded in a setup file or beforeAll for later tests
Record calls inside the test, or set test.clearMocks: false to get the 4.x behaviour

Since 5.0 clearMocks defaults to true and wipes call history before every test.

vi.mock('./some-path', () => 'hello') (Jest-style factory)
vi.mock('./some-path', () => ({ default: 'hello' }))

In Vitest the factory returns an object with every export, including default.

Questions

Do I have to use Vite to use Vitest?

No. It is built for Vite projects, and the docs call it a solid alternative for projects without Vite too.

Can I keep my Jest tests?

Mostly yes. Differences include no global test functions by default and a different module mock factory shape.

How do I fake network requests in tests?

The docs recommend Mock Service Worker (MSW), which intercepts requests without changes to your app code.

Which coverage tool does it use?

V8 by default, or Istanbul if you choose it; both come as optional extra packages.

Is it maintained?

Yes. Version 5.1.0 was published on 2026-11-02, after the 5.0 release with its own migration guide.