Skip to main content

Vitest Integration

Run your Vitest tests as usual and have results automatically reported to ProvaLab.io. Vitest is the fastest test runner for Vite-based projects, and ProvaLab.io integrates natively with its reporter API.

Install

npm install tms-node-sdk

Requirements: Node.js >= 18.0.0, Vitest >= 0.30.0

Configure

1. Set environment variables

export TMS_API_KEY=your-api-key
export TMS_API_URL=https://tms.yourcompany.com
export TMS_ORGANIZATION_ID=1
export TMS_PROJECT_ID=12

2. Add the ProvaLab.io reporter to your Vitest config

vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
reporters: [
'default', // Keep the default console output
'tms-node-sdk/vitest/reporter', // Add ProvaLab.io reporting
],
},
});

If using vite.config.ts instead:

vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
test: {
reporters: [
'default',
'tms-node-sdk/vitest/reporter',
],
},
});

Run

npx vitest run
Use vitest run for CI

Use vitest run (not just vitest) to run tests once and exit. The default vitest command starts watch mode, which will create multiple test runs in ProvaLab.io.

You'll see ProvaLab.io output alongside Vitest's normal output:

========================================
ProvaLab.io Vitest Integration
========================================
Test Run ID: 851
Project ID: 12
Organization ID: 1
========================================

[PASS] math > utils > should add numbers (0.01s)
[PASS] math > utils > should multiply numbers (0.01s)
[FAIL] math > utils > should handle division by zero (0.02s)

========================================
ProvaLab.io Test Run Summary
========================================
Test Run ID: 851
Total: 3
Passed: 2
Failed: 1
Skipped: 0
Status: FAILED
========================================

View Results in ProvaLab.io

  1. Open ProvaLab.io and go to your project
  2. Click Test Runs in the sidebar
  3. Find the run named "Vitest: 2026-02-20 14:30:00" (or your custom name)
  4. Click into it to see individual test results with error details

Option 1: Include the ID in the test title

import { describe, it, expect } from 'vitest';

describe('math utils', () => {
it('[TMS-501] should add numbers', () => {
expect(add(2, 3)).toBe(5);
});

it('[TMS-502] should multiply numbers', () => {
expect(multiply(2, 3)).toBe(6);
});
});

Option 2: Use a mapping file

test-case-mapping.json
{
"math utils > should add numbers": { "id": 501, "priority": "medium" },
"math utils > should multiply numbers": { "id": 502, "priority": "medium" }
}
export TMS_MAPPING_FILE=test-case-mapping.json
Vitest test name format

Vitest maps test names as describe > nested describe > test name using > as the separator, matching its suite hierarchy. Use this format in your mapping file.

Advanced Configuration

Custom test run name

export TMS_TEST_RUN_NAME="Unit Tests - Vue Components"

Environment tagging

export TMS_ENVIRONMENT=staging

Disable ProvaLab.io for local development

export TMS_DISABLED=true
npx vitest run

Use with workspace mode

If you use Vitest workspaces, add the reporter to each workspace config or to the root config:

vitest.workspace.ts
import { defineWorkspace } from 'vitest/config';

export default defineWorkspace([
{
test: {
name: 'unit',
include: ['src/**/*.test.ts'],
reporters: ['default', 'tms-node-sdk/vitest/reporter'],
},
},
{
test: {
name: 'integration',
include: ['tests/**/*.test.ts'],
reporters: ['default', 'tms-node-sdk/vitest/reporter'],
},
},
]);

Verify It Works

  1. Set your environment variables
  2. Create a simple test:
src/__tests__/tms-verify.test.ts
import { describe, it, expect } from 'vitest';

describe('TMS Integration', () => {
it('[TMS-1] verify TMS integration', () => {
expect(1 + 1).toBe(2);
});
});
  1. Run it:
npx vitest run src/__tests__/tms-verify.test.ts
  1. Check the console output for the ProvaLab.io banner with a Test Run ID
  2. Open ProvaLab.io and confirm the test run appears under your project
Common issues
  • "Not configured" message: Make sure TMS_API_KEY, TMS_ORGANIZATION_ID, and TMS_PROJECT_ID are all set
  • Watch mode creates multiple runs: Use vitest run for single execution, not vitest which defaults to watch mode
  • Reporter not loading: Ensure the path is tms-node-sdk/vitest/reporter in the reporters array