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
| Option | Type | Default | Description |
|---|---|---|---|
outputPath | string | ./test-results/analytics-timeline.json | Where to write the JSON report |
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 |
navigationTypes | NavigationType[] | null | null (all) | Filter timeline to specific navigation types |
redactPatterns | (string | RegExp)[] | Built-in patterns | Additional patterns to redact from error output |
testRunId | string | null | null (auto UUID) | Override the test run ID |
metadata | Record<string, unknown> | null | null | Attach 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.
navigationTypes
Filter the timeline to only include specific navigation types. By default, all types are included.
Available types:
goto—page.goto()callslink_click— Link clicks viapage.click()back— Browser back buttonforward— Browser forward buttonspa_route— Single-page app route changeshash_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
}]
]