Vitest
npm install @tracera/vitest
Requires Node.js ≥ 22.19 (see Autotest adapters). @tracera/vitest on npm.
In vitest.config.ts:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
runner: '@tracera/vitest/runner',
setupFiles: ['@tracera/vitest/setup'],
reporters: ['default', '@tracera/vitest/reporter'],
},
});
Only the final Vitest attempt is reported when retries are enabled. If that attempt is a retry (retry > 0), the result Env tab includes VITEST_RETRY (1 is the second run).
Environment variables and run mode: Autotest adapters.
Bind testCaseId and autotestName
Import test / expect / hooks from vitest, and tracera / annotations from @tracera/vitest. The custom runner is required so steps in stock hooks go to Setup / Teardown (Vitest freezes hook exports). @tracera/vitest/setup opens the per-test context. If you omit autotestName, the adapter uses the Vitest test title.
At declaration (preferred — bind runs even if the body skips early):
import { test, expect } from 'vitest';
import { annotations } from '@tracera/vitest';
test('login', { meta: annotations(42, 'e2e/login') }, async () => {
expect(true).toBe(true);
});
Inside the test (optional if annotations already bind the case):
import { test, expect } from 'vitest';
import { tracera } from '@tracera/vitest';
test('login', async () => {
tracera.testCase(42, 'e2e/login');
expect(true).toBe(true);
});
Steps
Use tracera.step. With runner: "@tracera/vitest/runner", steps inside stock beforeEach / afterEach go to Setup / Teardown.
import { test, beforeEach, afterEach } from 'vitest';
import { tracera } from '@tracera/vitest';
beforeEach(async () => {
await tracera.step('open shop', async () => {
// …
});
});
test('checkout', async () => {
tracera.testCase(10, 'e2e/checkout');
await tracera.step('add to cart', async () => {
// …
});
});
afterEach(async () => {
await tracera.step('cleanup', async () => {
// …
});
});
Comments, errors, and attachments
Inside a step — fields on that step. Outside a step — fields on the result. Use tracera.attachment for files (at most 10 on the result and on each step).
import { test } from 'vitest';
import { tracera } from '@tracera/vitest';
test('login', async () => {
tracera.testCase(42, 'e2e/login');
tracera.comment('result-level note');
tracera.error('result-level error text');
await tracera.step('open login', async () => {
tracera.comment('landed on login');
tracera.attachment({
fileName: 'suite-log.txt',
mimeType: 'text/plain',
data: new TextEncoder().encode('finished login flow'),
});
});
});