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/LICENSE3. Used by agents' projects
Dependency in 1,312 public GitHub projects set up for AI coding agents that we scanned (21.0%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
vitest.dev/llms.txtFrom 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
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
Often used with
Vitest in practice
Strengths
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.
The docs say the API is compatible enough to serve as "a drop-in replacement in most projects." Mocking, snapshots and coverage come included.
The site says watch mode reruns only the tests related to a change, "just like HMR for tests."
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
The current docs state that Vitest requires Vite <code>>=v6.4.0</code> and Node <code>>=v22.12.0</code>.
The docs call Browser Mode "Not a Drop-In Replacement" for standalone end-to-end runners. They recommend adding WebdriverIO, Cypress or Playwright.
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
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
Head to head
- Vitest vs Jest used together in 61 projects
- Vitest vs Nx Jest Plugin used together in 24 projects
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
Alternatives
Vitest This page
Pick Jest when an existing project already runs on it and you do not want to switch.
Pick Playwright Test for end-to-end tests that click through the whole app in several browsers.
Pick pytest when the code under test is Python.
Nx plugin providing Jest testing capabilities and executors for monorepo projects.
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.”
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 vitestFrom vitest.dev/guide/
Add a test script to package.json and run it.
{ "scripts": { "test": "vitest" } }From vitest.dev/guide/
Rules for your agent
## 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
Vitest does not turn global test functions on by default.
vi.mock is hoisted to the top of the file; since 5.0 a nested call throws instead of warning.
Since 5.0 an unawaited async assertion fails the test instead of printing a warning.
Since 5.0 clearMocks defaults to true and wipes call history before every test.
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.