Skip to main content

Vitest Reporter

The Testream Vitest Reporter generates a CTRF report from your Vitest test run and uploads the results to Testream.

Installation

npm install --save-dev @testream/vitest-reporter

Basic Configuration

Add the reporter to your vitest.config.ts:

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

export default defineConfig({
test: {
reporters: [
"default",
[
"@testream/vitest-reporter",
{
apiKey: process.env.TESTREAM_API_KEY,
uploadEnabled: true,
},
],
],
},
});

Configuration Options

OptionTypeDefaultDescription
apiKeystring-Required Testream API key
uploadEnabledbooleantrueEnable/disable automatic upload
failOnUploadErrorbooleanfalseFail the test run if upload fails
outputDirstringctrfCTRF output directory
outputFilestringctrf-report.jsonCTRF report filename
branchstringauto (CI)Git branch name
commitShastringauto (CI)Git commit SHA
repositoryUrlstringauto (CI)Git repository URL
buildNamestring-Build name/identifier
buildNumberstringauto (CI)Build number
buildUrlstringauto (CI)Build URL
testEnvironmentstring-Test environment (e.g., ci, staging)
appNamestring-Application name
appVersionstring-Application version
testTypestringunitTest type (e.g., unit, integration, e2e)

Full Configuration Example

vitest.config.ts
import { defineConfig } from "vitest/config";
import { loadEnv } from "vite";

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");

return {
test: {
include: ["__tests__/**/*.test.ts"],
reporters: [
"default",
[
"@testream/vitest-reporter",
{
apiKey: process.env.TESTREAM_API_KEY || env.TESTREAM_API_KEY,
uploadEnabled: true,
failOnUploadError: true,
testEnvironment: env.TESTREAM_TEST_ENVIRONMENT || "local",
appName: env.TESTREAM_APP_NAME || "vitest-example",
appVersion: env.TESTREAM_APP_VERSION || "1.0.0",
testType: env.TESTREAM_TEST_TYPE || "unit",
},
],
],
},
};
});

Notes

  • The reporter writes the CTRF report to ctrf/ctrf-report.json by default.
  • Git context (branch/commit/repository) is auto-detected in many CI environments if not provided.

Sample Project

The testream/vitest-jira-reporter repository is a complete working example of a Vitest project integrated with Testream. It includes example tests, full reporter configuration, and a ready-to-use GitHub Actions workflow.

NPM Package

What's Next?