
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 // 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 ) }) npx vitest # runs in watch mode by default np
Continue reading on Dev.to JavaScript
Opens in a new tab




