Skip to main content

Configuration

Configure TestRelic reporter behavior through options passed in your playwright.config.ts.

Basic Configuration

import { defineConfig } from '@playwright/test';

export default defineConfig({
reporter: [
['@testrelic/playwright-analytics', {
// Configuration options here
outputPath: './test-results/analytics-timeline.json',
includeNetworkStats: true,
}],
],
});

All Options

OptionTypeDefaultDescription
outputPathstring./test-results/analytics-timeline.jsonWhere to write the JSON report
includeStackTracebooleanfalseInclude full stack traces in failure diagnostics
includeCodeSnippetsbooleantrueInclude source code snippets around the failure line
codeContextLinesnumber3Lines of context above/below the failure line
includeNetworkStatsbooleantrueTrack network requests and bytes per navigation
navigationTypesNavigationType[] | nullnull (all)Filter timeline to specific navigation types
redactPatterns(string | RegExp)[]Built-in patternsAdditional patterns to redact from error output
testRunIdstring | nullnull (auto UUID)Override the test run ID
metadataRecord<string, unknown> | nullnullAttach custom metadata to the report

Detailed Options

outputPath

Specifies where the JSON report will be written. Can be an absolute or relative path.

{
outputPath: './custom-output/report.json'
}

includeStackTrace

When true, includes the full stack trace in failure diagnostics. Useful for debugging but increases report size.

{
includeStackTrace: true
}

includeCodeSnippets

When true (default), includes source code snippets showing the line where a test failed, plus surrounding context lines.

{
includeCodeSnippets: true,
codeContextLines: 5 // Show 5 lines before and after
}

includeNetworkStats

When true (default), tracks all network requests during each navigation and includes statistics in the report.

{
includeNetworkStats: true
}

Disabling this can improve performance for tests with many network requests.

Filter the timeline to only include specific navigation types. By default, all types are included.

Available types:

  • gotopage.goto() calls
  • link_click — Link clicks via page.click()
  • back — Browser back button
  • forward — Browser forward button
  • spa_route — Single-page app route changes
  • hash_change — URL hash changes
{
navigationTypes: ['goto', 'link_click'] // Only track these types
}

redactPatterns

Additional patterns to redact from error messages and stack traces. Built-in patterns already cover common secrets like AWS keys, Bearer tokens, and private keys.

{
redactPatterns: [
/api_key=[^&\s]+/gi,
/password=[^&\s]+/gi
]
}

testRunId

Override the automatically generated test run ID with a custom value. Useful for correlating with external systems.

{
testRunId: process.env.CI_BUILD_ID || null
}

metadata

Attach custom metadata to the report. This can be any JSON-serializable object.

{
metadata: {
environment: 'staging',
version: '1.2.3',
customField: 'custom value'
}
}

Configuration Examples

Minimal Configuration

reporter: [
['@testrelic/playwright-analytics']
]

Development Configuration

Verbose output with full diagnostics:

reporter: [
['@testrelic/playwright-analytics', {
outputPath: './dev-reports/analytics.json',
includeStackTrace: true,
includeCodeSnippets: true,
codeContextLines: 5,
includeNetworkStats: true,
}]
]

CI Configuration

Optimized for CI with custom metadata:

reporter: [
['@testrelic/playwright-analytics', {
outputPath: './ci-reports/analytics.json',
includeStackTrace: false,
includeNetworkStats: true,
testRunId: process.env.CI_BUILD_ID,
metadata: {
branch: process.env.CI_BRANCH,
commit: process.env.CI_COMMIT_SHA,
buildUrl: process.env.CI_BUILD_URL,
}
}]
]

Performance-Optimized Configuration

Minimal overhead for large test suites:

reporter: [
['@testrelic/playwright-analytics', {
includeStackTrace: false,
includeCodeSnippets: false,
includeNetworkStats: false,
navigationTypes: ['goto'] // Only track explicit navigations
}]
]
Was this doc helpful?