Skip to main content
Ask AI

Configuration

testrelic-playwright is configured through a single testrelic_options list in your pytest config, with a few common toggles also exposed as CLI flags and cloud settings as environment variables.

Where to set options

Use either pyproject.toml or pytest.ini. The keys and values are identical; only the surrounding syntax differs.

pyproject.toml
[tool.pytest.ini_options]
testrelic_options = [
"outputPath = ./test-results/analytics-timeline.json",
"includeStackTrace = true",
"codeContextLines = 5",
]
pytest.ini
[pytest]
testrelic_options =
outputPath = ./test-results/analytics-timeline.json
includeStackTrace = true
codeContextLines = 5

testrelic_options reference

KeyTypeDefaultDescription
outputPathstr./test-results/analytics-timeline.jsonJSON report path
htmlReportPathstrderived from outputPathHTML report path
includeStackTraceboolfalseFull stack traces in failures
includeCodeSnippetsbooltrueSource code around the failure line
codeContextLinesint3Context lines above/below the failure
includeNetworkStatsbooltrueTrack requests + bytes per navigation
includeArtifactsbooltrueInclude screenshots and videos
includeActionStepsbooltrueCapture pytest test steps
captureConsoleLogsbooltrueCapture browser console messages
trackApiCallsbooltrueEnable/disable API call tracking
captureRequestHeadersbooltrueCapture request headers
captureResponseHeadersbooltrueCapture response headers
captureRequestBodybooltrueCapture request bodies
captureResponseBodybooltrueCapture response bodies
redactHeaderslist[str][authorization, cookie, set-cookie, x-api-key]Header names to redact
redactBodyFieldslist[str][password, secret, token, apiKey, api_key]Body field names to redact
apiIncludeUrlslist[str][]Only track API calls matching these patterns (glob/regex)
apiExcludeUrlslist[str][]Exclude matching API calls (takes precedence)
captureAssertionsbooltrueCapture expect() assertion results
openReportbooltrueAuto-open the HTML report after a run (skipped in CI)
reportModestrautoembedded, streaming, or auto (streams large suites to disk)
streamingThresholdint500Test count at which auto switches to streaming
quietboolfalseSuppress the banner + terminal summary

CLI flags

A few options can be overridden on the command line without editing config:

FlagEffect
--testrelic-output PATHOverride the JSON report path (outputPath)
--testrelic-disableDisable the plugin for this run
--testrelic-quietSuppress the banner and terminal summary
Terminal
pytest --testrelic-output ./build/timeline.json --testrelic-quiet

Environment variables

Cloud upload is configured with environment variables:

VariableDefaultPurpose
TESTRELIC_API_KEYAPI key (required for cloud upload)
TESTRELIC_CLOUD_ENDPOINThttps://platform.testrelic.ai/api/v1Cloud endpoint override
TESTRELIC_UPLOAD_STRATEGYrealtime or batch upload
TESTRELIC_CLOUD_TIMEOUTUpload request timeout

See the Cloud Quickstart for the full upload flow.

Report mode and streaming

reportMode controls how the report is generated:

  • embedded — always produce a single self-contained HTML file.
  • streaming — always stream the report to a .testrelic-report directory.
  • auto (default) — use embedded until the test count reaches streamingThreshold (default 500), then switch to streaming.

Streamed reports are served with testrelic-playwright serve — see Reports.

Redaction

Sensitive data is redacted before it is written to disk or uploaded. Two lists control this:

  • redactHeaders — header names whose values are masked (default authorization, cookie, set-cookie, x-api-key).
  • redactBodyFields — body field names whose values are masked (default password, secret, token, apiKey, api_key).
pyproject.toml
[tool.pytest.ini_options]
testrelic_options = [
"redactHeaders = [authorization, cookie, x-internal-token]",
"redactBodyFields = [password, ssn, credit_card]",
]

Filtering tracked API calls

Use apiIncludeUrls and apiExcludeUrls to narrow which API calls are tracked. Both accept glob or regex patterns, and exclude takes precedence over include.

pyproject.toml
[tool.pytest.ini_options]
testrelic_options = [
"apiIncludeUrls = [https://api.example.com/*]",
"apiExcludeUrls = [*/health, */metrics]",
]

Next steps