DEV Community

Alex Spinov
Alex Spinov

Posted on

Vitest Has a Free Test Runner — Blazing Fast Testing with Vite-Native Speed

A developer ran Jest on a TypeScript project. Transform step took 8 seconds before a single test ran. On a 500-test suite, watch mode felt like watching paint dry.

Vitest is a Vite-native test runner. Same config as your Vite app. Instant transforms, HMR for tests, Jest-compatible API.

What Vitest Offers for Free

  • Vite-Powered - Instant transforms, no compilation step
  • Jest Compatible - Same API (describe, it, expect)
  • Watch Mode - Re-runs only affected tests instantly
  • TypeScript - Native TS support, no config
  • In-Source Testing - Write tests next to code
  • Coverage - Built-in code coverage (c8/istanbul)
  • UI - Visual test runner in browser
  • Workspace - Monorepo support
  • Snapshot - Snapshot testing built in
  • Mocking - Built-in mocking (vi.mock, vi.fn)

Quick Start

npm install -D vitest
Enter fullscreen mode Exit fullscreen mode
// math.test.ts
import { expect, test } from 'vitest'
import { sum } from './math'

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3)
})
Enter fullscreen mode Exit fullscreen mode
npx vitest  # runs in watch mode by default
npx vitest run  # single run for CI
Enter fullscreen mode Exit fullscreen mode

GitHub: vitest-dev/vitest - 13K+ stars


Need to monitor and scrape data from multiple web services automatically? I build custom scraping solutions. Check out my web scraping toolkit or email me at spinov001@gmail.com for a tailored solution.

Top comments (0)