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
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:
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
vitest run for CIUse 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
- Open ProvaLab.io and go to your project
- Click Test Runs in the sidebar
- Find the run named "Vitest: 2026-02-20 14:30:00" (or your custom name)
- Click into it to see individual test results with error details
Link Tests to ProvaLab.io Test Cases
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
{
"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 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:
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
- Set your environment variables
- Create a simple test:
import { describe, it, expect } from 'vitest';
describe('TMS Integration', () => {
it('[TMS-1] verify TMS integration', () => {
expect(1 + 1).toBe(2);
});
});
- Run it:
npx vitest run src/__tests__/tms-verify.test.ts
- Check the console output for the ProvaLab.io banner with a Test Run ID
- Open ProvaLab.io and confirm the test run appears under your project
- "Not configured" message: Make sure
TMS_API_KEY,TMS_ORGANIZATION_ID, andTMS_PROJECT_IDare all set - Watch mode creates multiple runs: Use
vitest runfor single execution, notvitestwhich defaults to watch mode - Reporter not loading: Ensure the path is
tms-node-sdk/vitest/reporterin thereportersarray