Vitest
Next generation testing framework powered by Vite.
Install / Use
/learn @vitest-dev/VitestREADME
<p align="center">
<br>
<br>
<a href="https://vitest.dev" target="_blank" rel="noopener noreferrer">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://vitest.dev/vitest-light.svg">
<source media="(prefers-color-scheme: light)" srcset="https://vitest.dev/vitest-dark.svg">
<img alt="Vitest logo" src="https://vitest.dev/vitest-dark.svg" height="60">
</picture>
</a>
<br>
<br>
<br>
</p>
<h1 align="center">
Vitest
</h1>
<p align="center">
Next generation testing framework powered by Vite.
<p>
<p align="center">
<a href="https://npmx.dev/package/vitest"><img src="https://img.shields.io/npm/v/vitest?color=729B1B&label=" alt="current vitest version badge"></a>
<p>
<p align="center">
<a href="https://chat.vitest.dev"><b>Get involved!</b></a>
</p>
<p align="center">
<a href="https://vitest.dev">Documentation</a> | <a href="https://vitest.dev/guide/">Getting Started</a> | <a href="https://vitest.dev/guide/#examples">Examples</a> | <a href="https://vitest.dev/guide/why">Why Vitest?</a>
</p>
<p align="center">
<a href="https://cn.vitest.dev">中文文档</a>
</p>
<h4 align="center">
</h4>
<br>
<br>
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
v8oristanbul. - Tinyspy built-in for 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.0.0 and Node >=v20.0.0
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()
})
})
$ npx vitest
Sponsors
<p align="center"> <a href="https://cdn.jsdelivr.net/gh/sheremet-va/static/vitest/sponsors.svg"> <img src='https://cdn.jsdelivr.net/gh/sheremet-va/static/vitest/sponsors.svg' alt="vitest's sponsors"/> </a> </p>Vladimir Sponsors
<p align="center"> <a href="https://cdn.jsdelivr.net/gh/sheremet-va/static/sponsors.svg"> <img src='https://cdn.jsdelivr.net/gh/sheremet-va/static/sponsors.svg' alt="vladimir's sponsors"/> </a> </p>Anthony Fu Sponsors
<p align="center"> <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg' alt="anthony's sponsors"/> </a> </p>Patak Sponsors
<p align="center"> <a href="https://cdn.jsdelivr.net/gh/patak-dev/static/sponsors.svg"> <img src='https://cdn.jsdelivr.net/gh/patak-dev/static/sponsors.svg' alt="patak's sponsors"/> </a> </p>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 contributors
Related Skills
node-connect
334.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
334.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.1kCommit, push, and open a PR
