Skip to main content

Playwright Reporter

The Testream Playwright Reporter generates CTRF reports and uploads test results (plus artifacts) to Testream.

Installation

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

Basic Configuration

Add the reporter to your playwright.config.ts:

playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
reporter: [
['@testream/playwright-reporter', {
apiKey: process.env.TESTREAM_API_KEY,
uploadEnabled: true,
}],
['html'],
],
});

Configuration Options

OptionTypeDefaultDescription
apiKeystring-Required Testream API key
uploadEnabledbooleantrueEnable/disable automatic upload
failOnUploadErrorbooleanfalseFail the test run if upload fails
branchstringautoGit branch name
commitShastringautoGit commit SHA
repositoryUrlstringautoGit repository URL
outputFilestringctrf-report.jsonCTRF report filename
outputDirstringctrfCTRF output directory
screenshotbooleantrueInclude screenshots in CTRF
annotationsbooleanfalseInclude Playwright annotations
testTypestringe2eTest type (e.g., api, unit)
appNamestring-Application name
appVersionstring-Application version
buildNamestring-Build name
buildNumberstring-Build number
buildUrlstring-Build URL
testEnvironmentstring-Environment name

Full Configuration Example

playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['@testream/playwright-reporter', {
apiKey: process.env.TESTREAM_API_KEY,
uploadEnabled: true,
failOnUploadError: true,
branch: process.env.GITHUB_REF_NAME,
commitSha: process.env.GITHUB_SHA,
repositoryUrl: process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY
? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}`
: undefined,
outputFile: 'ctrf-report.json',
outputDir: 'ctrf',
screenshot: true,
annotations: true,
testType: 'e2e',
appName: 'My App',
appVersion: '1.0.0',
buildName: process.env.GITHUB_WORKFLOW,
buildNumber: process.env.GITHUB_RUN_NUMBER,
buildUrl: process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY && process.env.GITHUB_RUN_ID
? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
: undefined,
testEnvironment: process.env.TEST_ENV || 'ci',
}],
['html', { open: 'never' }],
['list'],
],
use: {
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
],
});

Notes on Artifacts

Playwright artifacts (screenshots, videos, traces) are uploaded automatically when they are attached to tests. Keep Playwright artifact capture enabled in use and the reporter will pick them up.

NPM Package

What's Next?