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.
[tool.pytest.ini_options]
testrelic_options = [
"outputPath = ./test-results/analytics-timeline.json",
"includeStackTrace = true",
"codeContextLines = 5",
]
[pytest]
testrelic_options =
outputPath = ./test-results/analytics-timeline.json
includeStackTrace = true
codeContextLines = 5
testrelic_options reference
| Key | Type | Default | Description |
|---|---|---|---|
outputPath | str | ./test-results/analytics-timeline.json | JSON report path |
htmlReportPath | str | derived from outputPath | HTML report path |
includeStackTrace | bool | false | Full stack traces in failures |
includeCodeSnippets | bool | true | Source code around the failure line |
codeContextLines | int | 3 | Context lines above/below the failure |
includeNetworkStats | bool | true | Track requests + bytes per navigation |
includeArtifacts | bool | true | Include screenshots and videos |
includeActionSteps | bool | true | Capture pytest test steps |
captureConsoleLogs | bool | true | Capture browser console messages |
trackApiCalls | bool | true | Enable/disable API call tracking |
captureRequestHeaders | bool | true | Capture request headers |
captureResponseHeaders | bool | true | Capture response headers |
captureRequestBody | bool | true | Capture request bodies |
captureResponseBody | bool | true | Capture response bodies |
redactHeaders | list[str] | [authorization, cookie, set-cookie, x-api-key] | Header names to redact |
redactBodyFields | list[str] | [password, secret, token, apiKey, api_key] | Body field names to redact |
apiIncludeUrls | list[str] | [] | Only track API calls matching these patterns (glob/regex) |
apiExcludeUrls | list[str] | [] | Exclude matching API calls (takes precedence) |
captureAssertions | bool | true | Capture expect() assertion results |
openReport | bool | true | Auto-open the HTML report after a run (skipped in CI) |
reportMode | str | auto | embedded, streaming, or auto (streams large suites to disk) |
streamingThreshold | int | 500 | Test count at which auto switches to streaming |
quiet | bool | false | Suppress the banner + terminal summary |
CLI flags
A few options can be overridden on the command line without editing config:
| Flag | Effect |
|---|---|
--testrelic-output PATH | Override the JSON report path (outputPath) |
--testrelic-disable | Disable the plugin for this run |
--testrelic-quiet | Suppress the banner and terminal summary |
pytest --testrelic-output ./build/timeline.json --testrelic-quiet
Environment variables
Cloud upload is configured with environment variables:
| Variable | Default | Purpose |
|---|---|---|
TESTRELIC_API_KEY | — | API key (required for cloud upload) |
TESTRELIC_CLOUD_ENDPOINT | https://platform.testrelic.ai/api/v1 | Cloud endpoint override |
TESTRELIC_UPLOAD_STRATEGY | — | realtime or batch upload |
TESTRELIC_CLOUD_TIMEOUT | — | Upload 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-reportdirectory.auto(default) — useembeddeduntil the test count reachesstreamingThreshold(default500), then switch tostreaming.
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 (defaultauthorization,cookie,set-cookie,x-api-key).redactBodyFields— body field names whose values are masked (defaultpassword,secret,token,apiKey,api_key).
[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.
[tool.pytest.ini_options]
testrelic_options = [
"apiIncludeUrls = [https://api.example.com/*]",
"apiExcludeUrls = [*/health, */metrics]",
]