Skip to main content
Ask AI

Configuration

Appium / WDIO configuration

This page covers @testrelic/playwright-analytics configuration options. For Appium mobile testing with WebdriverIO, see the Configuration Reference in @testrelic/appium-analytics.

Purpose

Tune what the reporter captures (stack traces, snippets, network, streaming, metadata) through the options object in playwright.config.ts. Use the tables below as the authoritative field reference.

Concept: how options shape the analytics JSON

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.json'Where 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
captureRequestBodybooleanfalseInclude request body in network capture
captureResponseBodybooleanfalseInclude response body in network capture
navigationTypesNavigationType[] | nullnull (all)Filter timeline to specific navigation types
redactPatterns(string | RegExp)[][] (additional only)Extra patterns appended to the built-in redaction set
testRunIdstring | nullnull (auto UUID)Override the test run ID
metadataRecord<string, unknown> | nullnullAttach custom metadata to the report
reportMode'streaming' | 'batched''streaming'How the reporter writes the JSON file
streamingThresholdnumber0Minimum test count before streaming is active

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. The reporter already applies built-in redaction patterns that cover AWS access keys, Bearer tokens, and PEM private key blocks. The redactPatterns option appends additional patterns — it does not replace the built-ins.

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

How profiles compare (conceptual)

Radar axes match the kinds of toggles on this page (traces, snippets, network, metadata, overall verbosity). Use it as a mental model, then dial real options in playwright.config.ts.

Loading chart…

Troubleshooting

SymptomWhat to try
Very large JSON in CITurn off includeStackTrace / includeCodeSnippets, narrow navigationTypes, or disable includeNetworkStats for a CI-only reporter profile.
Missing code around failuresSet includeCodeSnippets to true and increase codeContextLines.

FAQ

Does `redactPatterns` replace the built-in secret redaction?
No. Custom patterns are appended to the built-in set described in the redaction section above.
What is the difference between `reportMode` streaming and batched?
Streaming writes incrementally as the suite runs; batched collects more in memory before flush. Defaults favor streaming — see the options table for `streamingThreshold`.
Can I use different reporter options locally versus in CI?
Yes. Many teams use environment checks in `playwright.config.ts` to export different `reporter` arrays for local and CI.