Configuration
Complete reference for configuring the TestRelic Playwright analytics reporter — output path, stack traces, network stats, redaction, and CI metadata.
Appium / WDIO configuration
This page covers @testrelic/playwright-analytics options. For Appium mobile testing with WebdriverIO, see Appium Configuration.
Tune what the reporter captures — stack traces, snippets, network, streaming, metadata — through the options object passed to the reporter in playwright.config.ts.
Common configuration patterns
Update my playwright.config.ts to use @testrelic/playwright-analytics with a CI
configuration that reads build metadata from environment variables:
['@testrelic/playwright-analytics', {
outputPath: './ci-reports/analytics.json',
includeStackTrace: false,
includeNetworkStats: true,
testRunId: process.env.CI_BUILD_ID || null,
metadata: {
branch: process.env.CI_BRANCH,
commit: process.env.CI_COMMIT_SHA,
buildUrl: process.env.CI_BUILD_URL,
}
}]
Show me the updated file.Update my @testrelic/playwright-analytics reporter configuration to redact sensitive
data patterns from reports. Add these redact patterns:
redactPatterns: [
/api_key=[^&\s]+/gi,
/password=[^&\s]+/gi,
/token=[^&\s]+/gi,
]
Show me the updated reporter configuration.Options reference
| Option | Type | Default | Description |
|---|---|---|---|
outputPath | string | './test-results/analytics-timeline.json' | Where to write the JSON report (embedded mode); its directory also holds the streaming report and artifacts |
htmlReportPath | string | outputPath with .html | Where to write the HTML report |
openReport | boolean | true | Open the HTML report after the run (skipped in CI) |
quiet | boolean | false | Suppress the console summary box |
includeStackTrace | boolean | false | Include full stack traces in failure diagnostics |
includeCodeSnippets | boolean | true | Include source code snippets around the failure line |
codeContextLines | number | 3 | Lines of context above/below the failure line |
includeNetworkStats | boolean | true | Track network requests and bytes per navigation |
trackApiCalls | boolean | true | Track request (APIRequestContext) calls in the fixtures |
captureRequestHeaders | boolean | true | Include request headers for tracked API calls |
captureResponseHeaders | boolean | true | Include response headers for tracked API calls |
captureRequestBody | boolean | true | Include the request body for tracked API calls |
captureResponseBody | boolean | true | Include the response body for tracked API calls |
redactHeaders | string[] | ['authorization', 'cookie', 'set-cookie', 'x-api-key'] | API header names (case-insensitive) whose values become [REDACTED]; setting it replaces the default list |
redactBodyFields | string[] | ['password', 'secret', 'token', 'apiKey', 'api_key'] | API body fields redacted at any depth; setting it replaces the default list |
apiIncludeUrls | (string | RegExp)[] | [] (track all) | Only track API calls matching these URL patterns |
apiExcludeUrls | (string | RegExp)[] | [] | Skip API calls matching these patterns; takes precedence over include |
includeActionSteps | boolean | true | Capture Playwright test steps/actions plus assertions, video-synced |
captureConsoleLogs | boolean | true | Capture browser console logs (E2E) and terminal output (API) per test |
captureAssertions | boolean | true | Capture expect() assertion results |
includeArtifacts | boolean | true | Capture screenshots, video, and trace artifacts |
captureNavigation | boolean | true | Capture the Test Navigation timeline; set false to drop it before upload |
captureChangedFiles | boolean | true | Send the paths (never contents) of files changed by the run's commit with the cloud upload |
navigationTypes | NavigationType[] | null | null (all) | Filter the timeline to specific navigation types, e.g. goto, navigation, link_click, form_submit, back, forward, refresh, redirect, popstate, spa_route, spa_replace, hash_change, page_load, manual_record |
redactPatterns | (string | RegExp)[] | [] (additional only) | Extra patterns appended to the built-in redaction set (AWS keys, Bearer tokens, PEM private keys, credentials in URLs) |
testRunId | string | null | null (auto UUID) | Override the test run ID — useful for correlating with external CI systems |
metadata | Record<string, unknown> | null | null | Attach custom metadata to the report |
reportMode | 'streaming' | 'embedded' | 'auto' | 'streaming' | streaming writes per-test files to .testrelic-report/ (view with npx testrelic serve); embedded writes one JSON file plus a self-contained HTML file; auto picks by suite size |
streamingThreshold | number | 0 | With reportMode: 'auto', suites with at least this many tests use streaming |
cloud | object | — | Cloud upload options — see Cloud upload |
Large runs always upload
You never lose a run to an upload size limit. When a run is large, the reporter automatically sheds optional detail in tiers — console and network logs first, then API-call detail, then remaining per-test detail, and as a last resort only the run summary — so the run still uploads. Each step prints a [testrelic] WARNING line. No configuration is required.
Cloud upload
Cloud upload turns on when an API key is found. Settings are merged from, highest priority first: environment variables, the reporter's cloud options, .testrelic/testrelic-config.json (discovered by walking up from the working directory), then built-in defaults.
['@testrelic/playwright-analytics', {
cloud: {
apiKey: process.env.TESTRELIC_API_KEY,
upload: 'both',
},
}]cloud option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | TestRelic API key. A '$VAR' string is read from that environment variable |
endpoint | string | 'https://platform.testrelic.ai/api/v1' | Cloud API endpoint |
upload | 'batch' | 'realtime' | 'both' | 'batch' | batch sends one payload at the end; realtime streams results as tests finish; both does both |
timeout | number | 30000 | Per-request timeout (ms) |
uploadBudgetMs | number | 120000 | Total time budget for the upload phase (ms), so a slow network cannot hold the run open |
projectName | string | — | Project name, used to identify the repository when there is no git remote |
uploadArtifacts | boolean | true | Upload screenshots, videos, traces and visual images |
artifactMaxSizeMb | number | 50 | Per-file size limit for artifact uploads (MB) |
queueMaxAge | string | '7d' | How long failed uploads stay queued for retry (s, m, h, d units) |
queueDirectory | string | '.testrelic/queue' | Where failed uploads are queued |
The repository is identified automatically from your git remote — no repository ID is needed. The same settings can live in .testrelic/testrelic-config.json (created by the package's postinstall outside CI); commit that file and ignore .testrelic/queue/ and .testrelic/cache/:
{
"cloud": { "apiKey": "$TESTRELIC_API_KEY", "upload": "both" },
"testrelic-repo": { "name": "my-project" },
"queue": { "maxAge": "7d", "directory": ".testrelic/queue" }
}Environment variables
| Variable | Effect |
|---|---|
TESTRELIC_API_KEY | API key (overrides every other source) |
TESTRELIC_CLOUD_ENDPOINT | Override the API endpoint |
TESTRELIC_UPLOAD_STRATEGY | batch, realtime or both |
TESTRELIC_CLOUD_TIMEOUT | Per-request timeout in ms (1000–120000) |
TESTRELIC_RUN_TYPE | Tag the run as smoke, regression, nightly or ci so it lands in the matching monitoring dashboard |
TESTRELIC_CLOUD_PLATFORM | browserstack or lambdatest — link the run to a remote browser-farm session. TESTRELIC_CLOUD_BUILD_ID and TESTRELIC_CLOUD_SESSION_ID add the vendor build/session; BrowserStack and LambdaTest env vars are detected automatically |
Troubleshooting
| Symptom | What to try |
|---|---|
| Very large JSON in CI | Turn off includeStackTrace / includeCodeSnippets, narrow navigationTypes, or disable includeNetworkStats for a CI-only profile. |
| Missing code around failures | Set includeCodeSnippets to true and increase codeContextLines. |