Configuration
Configure TestRelic reporter behavior through options passed in your playwright.config.ts.
How do I add TestRelic to my Playwright config?
- With AI Prompts
- Manual Steps
How do I configure TestRelic using an AI assistant?
Copy a prompt below and paste it into your AI coding assistant. Each prompt sets up the reporter for a specific scenario.
Full end-to-end setup (install + configure + fixture)
Use this to get everything working from scratch in one go:
Set up @testrelic/playwright-analytics in this project end to end:
1. Run: npm install @testrelic/playwright-analytics
2. Open playwright.config.ts and add the TestRelic reporter to the reporter array:
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeStackTrace: true,
includeCodeSnippets: true,
includeNetworkStats: true,
}]
3. In all test files that currently import from '@playwright/test', change the import
to '@testrelic/playwright-analytics/fixture' so navigation is tracked automatically.
Keep the existing 'list' reporter if it is already there. Do not change any test logic.
Development configuration prompt
Use this when you want detailed diagnostics during local development:
Update my playwright.config.ts to use @testrelic/playwright-analytics with a development
configuration that includes full stack traces, code snippets, and network stats:
['@testrelic/playwright-analytics', {
outputPath: './dev-reports/analytics.json',
includeStackTrace: true,
includeCodeSnippets: true,
codeContextLines: 5,
includeNetworkStats: true,
}]
Show me the updated file.
CI configuration prompt
Use this for a CI pipeline where you want to attach build metadata to each report:
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.
Performance-optimized configuration prompt
Use this for large test suites where you want to minimize reporter overhead:
Update my playwright.config.ts to use @testrelic/playwright-analytics with a
performance-optimized configuration that reduces overhead for large test suites:
['@testrelic/playwright-analytics', {
includeStackTrace: false,
includeCodeSnippets: false,
includeNetworkStats: false,
navigationTypes: ['goto'],
}]
Show me the updated file.
Redact sensitive data from reports prompt
Use this if your tests include API keys, passwords, or tokens that should not appear in reports:
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.
How do I add the reporter to my Playwright config?
Open playwright.config.ts and add the TestRelic reporter to the reporter array:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['list'],
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeStackTrace: true,
includeCodeSnippets: true,
includeNetworkStats: true,
}],
],
});
What are common configuration patterns?
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']
}]
]
What configuration options are available?
| 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 |
What does each option do?
How do I change where the report is saved?
Use outputPath. Accepts an absolute or relative path.
{
outputPath: './custom-output/report.json'
}
How do I enable full stack traces for failures?
Set includeStackTrace to true. This is useful for debugging but increases report size.
{
includeStackTrace: true
}
How do I control the code snippet around a failure?
Use includeCodeSnippets and codeContextLines. When includeCodeSnippets is true (the default), TestRelic shows the line where a test failed plus surrounding context lines.
{
includeCodeSnippets: true,
codeContextLines: 5 // Show 5 lines before and after
}
How do I disable network tracking?
Set includeNetworkStats to false. Disabling this can improve performance for tests with many network requests.
{
includeNetworkStats: false
}
How do I filter which navigation types appear in the timeline?
Use navigationTypes. 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
}
How do I redact sensitive data from reports?
Use redactPatterns. Built-in patterns already cover AWS keys, Bearer tokens, and private keys. Add your own patterns to extend redaction.
{
redactPatterns: [
/api_key=[^&\s]+/gi,
/password=[^&\s]+/gi
]
}
How do I set a custom test run ID?
Use testRunId. This is useful for correlating TestRelic reports with external CI systems.
{
testRunId: process.env.CI_BUILD_ID || null
}
How do I attach custom metadata to the report?
Use metadata. This accepts any JSON-serializable object.
{
metadata: {
environment: 'staging',
version: '1.2.3',
customField: 'custom value'
}
}