Spekra
Docs

Getting Started

  • Overview
  • Playwright
  • Jest
  • Vitest

Core Concepts

  • Flaky Tests
  • Stability Metrics
  • Test Identity

Reporters

  • Playwright
  • Playwright Config
  • Jest
  • Jest Config
  • Vitest
  • Vitest Config

Platform

  • Dashboard
  • Flaky Tests View
  • Test Runs
  • API Keys
  • Rate Limits

CI/CD

  • Overview
  • GitHub Actions
  • GitLab CI

Security

  • Overview
  • Data Handling
  • Compliance

Troubleshooting

  • Overview
  • Connection Issues
  • Missing Data
DocsReportersVitest

Vitest Reporter

The @spekra/vitest reporter integrates with Vitest to capture test results and send them to Spekra for flaky test detection and stability tracking.

Installation

npm install @spekra/vitest

Basic Configuration

Add the reporter to your Vitest configuration:

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    reporters: [
      'default',
      ['@spekra/vitest', {
        apiKey: process.env.SPEKRA_API_KEY,
        source: 'my-unit-tests', // Required: identifies your test suite
      }],
    ],
  },
});

How It Works

The reporter hooks into Vitest's test lifecycle:

  1. On init - Initializes when Vitest starts (skips if in watch mode)
  2. On task update - Captures individual test outcomes as they complete
  3. On finished - Batches and sends all results to Spekra

Non-Blocking Design

Like the Playwright and Jest reporters, the Vitest reporter is designed to be non-intrusive:

  • Results are sent asynchronously after tests complete
  • Network failures don't fail your build (unless failOnError is enabled)
  • Aggressive timeouts prevent hanging

Watch Mode

The reporter automatically disables itself in watch mode (vitest without run). This prevents noise from continuous test reruns during development. Results are only sent when running vitest run.

Data Captured

The reporter captures:

FieldSourceExample
testFileTest locationsrc/utils/format.test.ts
fullTitleSuite + test nameformatCurrency > handles zero values
suitePathDescribe hierarchy['formatCurrency']
testNameIt/test titlehandles zero values
projectWorkspace nameweb-app
statusTest outcomepassed, failed, skipped
durationMsExecution time12
retryRetry attempt0, 1, 2...
errorFailure messageExpected true, got false

Git & CI Information

The reporter also captures:

  • Git branch and commit SHA
  • CI provider and job URL
  • Shard information (when using --shard)

Workspace Support

Vitest workspaces are fully supported. The workspace name is captured as the project field:

// vitest.workspace.ts
export default [
  'packages/web-app',
  'packages/utils',
];

Tests from different workspaces will have their respective workspace names, allowing you to filter and analyze them separately in Spekra.

Sharding Support

When using Vitest's built-in sharding, shard information is automatically captured:

vitest run --shard=1/3

The reporter captures shardIndex and totalShards to properly aggregate results across parallel shards.

Differences from Playwright and Jest

Similar to Jest

The Vitest reporter follows the same pattern as the Jest reporter:

  • Requires a source identifier
  • Sends all results at the end of the run
  • No artifact uploads (traces, screenshots)

Workspace Support

Unlike Jest, Vitest has native workspace support similar to Playwright's projects. The workspace name is captured automatically.

Quick Links

Configuration Options

All available reporter options and their defaults.

Quick Start

Get up and running with Vitest in 5 minutes.

Previous

Jest Config

Next

Vitest Config