mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
Vitest
A blazing fast unit test framework powered by Vite.
Open the Docs
Get involved!
💖 This project is currently in closed beta exclusively for Sponsors.
Become a Sponsor of @patak-dev or @antfu to access the source code and issues tracker.
⚠️ DISCLAIMER: Vitest is still in development and not stable yet. It's not recommended to use it in production.
Vitest requires Vite v2.7 and Node v16
Switch to Vitest by following the Getting Started Guide or learn why we are building a new test runner.
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 c8
- Tinyspy built-in for mocking, stubbing, and spies.
- JSDOM and happy-dom for DOM and browser API mocking
- Components testing (Vue, React, Lit, Vitesse)
- Workers multi-threading via Piscina
- ESM first, top level await
- Out-of-box TypeScript / JSX support
- Filtering, timeouts, concurrent for suite and tests
import { it, describe, expect, assert } 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
Examples
- Unit Testing
- Vue Component Testing
- React Component Testing
- Lit Component Testing
- Vitesse Component Testing
Projects using Vitest
Sponsors
Credits
Thanks to:
- @patak-dev for the awesome package name!
- The Vite team for brainstorming the initial idea.
- @pi0 for the idea and implementation of using Vite to transform and bundle the server code.
- @lukeed for the work on uvu where we are inspired a lot from.
License
MIT License © 2021 Anthony Fu
Languages
TypeScript
94.4%
Vue
3.2%
JavaScript
2.2%
CSS
0.1%
HTML
0.1%