Skip to content

Running Tests

Commands

CommandDescription
npm testRun tests in watch mode (re-runs on changes)
npm run test:runSingle test run (CI-friendly)
npm run test:coverageGenerate coverage report
npm run test:uiOpen Vitest UI in browser

Watch Mode

bash
npm test

Vitest watches for file changes and re-runs affected tests. Press h in the terminal for interactive options.

Coverage

bash
npm run test:coverage

Generates a coverage report showing which lines, branches, and functions are tested.

Vitest UI

bash
npm run test:ui

Opens a browser-based dashboard at http://localhost:51204/__vitest__/ with:

  • Test file browser
  • Individual test results
  • Re-run capabilities
  • Coverage visualization

Configuration

Vitest is configured in vitest.config.ts:

typescript
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environment: 'happy-dom',
    setupFiles: ['./tests/setup.ts'],
  }
})

Built with VitePress