Skip to content

Vitest

Vitest is a blazing fast unit-test framework powered by Vite.

Install

Add it to your project with:

npm install -D vitest

If you've used Vite, Vitest will read the configuration from the vite.config.js file so add the test property there.

/// <reference types="vitest" />
import { defineConfig } from 'vite'

export default defineConfig({
  test: {
    // ...
  },
})

To run the tests use npx vitest, to see the coverage use npx vitest --coverage.

References