Vitest

4.1.4 · active · verified Sat Apr 18

Vitest is a next-generation testing framework powered by Vite, offering a fast and integrated testing experience. The current stable version is 4.1.4. It maintains a rapid release cycle, with frequent patch releases addressing bug fixes and minor features, alongside regular minor versions introducing new capabilities and experimental features.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates a basic Vitest test file, importing `test` and `expect` to define and assert a simple function. It's designed to be runnable by executing `npx vitest` in your project's terminal.

import { test, expect } from 'vitest';

function add(a: number, b: number): number {
  return a + b;
}

test('adds two numbers', () => {
  expect(add(1, 2)).toBe(3);
});

// To run: npx vitest

view raw JSON →