Skip to main content
Ask AI

Configuration

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

How do I add TestRelic to my Playwright config?

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:

AI Prompt — Full end-to-end setup
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:

AI Prompt — Development configuration
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:

AI Prompt — CI configuration
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:

AI Prompt — Performance-optimized configuration
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:

AI Prompt — Redact sensitive data
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.

What configuration options are available?

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

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:

  • 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
}

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'
}
}