vitest-dev /vitest
Next generation testing framework powered by Vite.
★ 17,378⑂ 2,186👁 60⑃ 5,971● 4,559▤ 468
+2
Daily
17,378
stars
2,186
forks
60
watchers
5,971
prs
4,559
issues
468
releases
README
Vitest
Next generation testing framework powered by Vite.
Get involved!
Documentation | Getting Started | Examples | Why Vitest?
中文文档
Features
- Vite's config, transformers, resolvers, and plugins. Use the same setup from your app!
- Jest Snapshot
- Chai built-in for assertions, with Jest expect compatible APIs
- Smart & instant watch mode, like HMR for tests!
- Native code coverage via v8 or istanbul.
- Jest-compatible mocking, stubbing, and spies.
- JSDOM and happy-dom for DOM and browser API mocking
- Browser Mode for running component tests in the browser
- Components testing (Vue, React, Svelte, Lit, Marko)
- Benchmarking support with Tinybench
- Projects support
- expect-type for type-level testing
- ESM first, top level await
- Out-of-box TypeScript / JSX support
- Filtering, timeouts, concurrent for suite and tests
- Sharding support
- Reporting Uncaught Errors
- Run your tests in the browser natively
Vitest requires Vite =v6.4.0 and Node =v22.12.0
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()
})
})
bash
$ npx vitest
Sponsors
Credits
Thanks to:
- The Jest team and community for creating a delightful testing API
- @lukeed for the work on uvu where we are inspired a lot from.
- @pi0 for the idea and implementation of using Vite to transform and bundle the server code.
- The Vite team for brainstorming the initial idea.
- @patak-dev for the awesome package name!
Contribution
See Contributing Guide.
License
MIT License © 2021-Present VoidZero Inc. and Vitest contributorsTop issues
#6553Regression: v2.1.0 makes folder globbing impossible in `vitest.workspace.ts` (No loader is configured for ".gitignore" files: .gitignore)25 comments · 2024-09-23#4899`@vitest/web-worker` error when using browser environment22 comments · 2024-01-08#9751Unify and simplify timeout configuration18 comments · 2026-02-26#8411MCP server for test results and coverage17 comments · 2025-08-08#7247Browser mode runs test twice in case of a self-importing svelte component15 comments · 2025-01-14#4750`expect.hasAssertions()` fails to mark the test as failed when using async function and callback15 comments · 2023-12-14#7881Basic reporter but with real time progress14 comments · 2025-04-24#5477Browser mode throws "Failed to fetch dynamically imported module" 14 comments · 2024-04-02
Discussions
#11966Open-source verification stack for AI-assisted Vite & TypeScript apps (headless Playwright QA, 92-rule security scanner & 72-rule UI linter)0 comments · 2026-11-14#11849why are chromium browsers so slow2 comments · 2026-11-03#11628CurlShot: testing a screenshot API with Vitest (unit suite + real-Chromium engine suite)0 comments · 2026-10-17#11579Using `vitest complete --` for wrapper CLI completions3 comments · 2026-10-14#11514IOTA Watch: contract tests that distinguish missing mining data from zero0 comments · 2026-10-06#11481fix(cache): don't cache tmp copies after write failure (fix #11452)0 comments · 2026-10-05#11480fix(reporter): avoid duplicate FAIL headers on retry (fix #11454)0 comments · 2026-10-05#11465fix(browser): avoid strict mode violation in failure screenshot with nested `<body>` (fix #11434)0 comments · 2026-10-04
Latest release
v5.1.0 v5.1.0 2026-11-02 🚀 Features - Add --last-failed to run only failed tests - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/11558 (82f63) - Support Temporal.Instant and Temporal.ZonedDateTime in vi.setSystemTime() - by @Prajwal2246, Prajwal2246, Claude Opus 5.5 (1M context), @hi-ogawa and Codex (GPT-6) in https://github.com/vitest-dev/vitest/issues/11321 (f150f) - Introduce --since-last-run flag - by @sheremet-va in https://github.com/vitest-dev/vitest/issues/11516 (08bd9) - Expose per-retry/repeat attempt result - by @hi-ogawa, C