Configuration
Full testrelic_options reference for testrelic-playwright, plus CLI flags, environment variables, report modes, redaction, and API URL filtering.
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 = 5testrelic_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 |
testRunId | str | generated | Use a fixed run ID instead of a generated one |
Values are parsed as true/false, none/null, numbers, or plain strings.
In the current release (0.3.11), list-valued options (redactHeaders, redactBodyFields, apiIncludeUrls, apiExcludeUrls) can't be set through testrelic_options: an ini value is read as a single string and rejected with a validation error when pytest starts. Leave them out of testrelic_options so the defaults apply.
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-quietEnvironment 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 | batch | realtime, batch, or both |
TESTRELIC_CLOUD_TIMEOUT | 30000 | Upload request timeout (milliseconds) |
TESTRELIC_RUN_TYPE | — | Dashboard bucket: smoke, regression, nightly, or ci |
TESTRELIC_CLOUD_PLATFORM | auto-detected | Label the run's device grid (browserstack or lambdatest) when auto-detection can't |
TESTRELIC_CLOUD_BUILD_ID / TESTRELIC_CLOUD_SESSION_ID | — | Grid build and session IDs to attach, used with TESTRELIC_CLOUD_PLATFORM |
Cloud settings can also live in .testrelic/testrelic-config.json (found by walking up from the working directory). Environment variables win over the file, and $VAR / ${VAR} references in it are expanded:
{
"cloud": {
"apiKey": "$TESTRELIC_API_KEY",
"upload": "both"
},
"testrelic-repo": { "name": "my-project" },
"queue": { "directory": ".testrelic/queue", "maxAge": "7d" }
}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).
Built-in patterns also mask AWS access keys, bearer tokens, private keys, and credentials embedded in URLs. As noted above, these lists can't yet be overridden through testrelic_options, so the defaults apply.
Filtering tracked API calls
apiIncludeUrls and apiExcludeUrls narrow which API calls are tracked. Both accept glob or regex patterns, and exclude takes precedence over include. Like the redaction lists, they can't yet be set through testrelic_options in 0.3.11, so all APIRequestContext calls are tracked unless you turn tracking off with trackApiCalls = false.
Automatic detection
Two things are detected with no configuration:
- Navigation, including SPA / client-side route changes that don't reload the page, is tracked automatically and appears in the timeline.
- CI provider — GitHub Actions, GitLab CI, Jenkins, CircleCI, and Bitbucket Pipelines are recognized automatically, attaching branch, commit, and run URL to the run. Outside CI, the
openReportauto-open applies; inside CI it is skipped.
Next steps
Cloud Quickstart
Set a TestRelic API key, configure cloud upload for your Playwright Python runs, and view results in the cloud dashboard and Session Workspace.
Examples
Practical testrelic-playwright examples: browser E2E, API tests, unified tests, large-suite streaming, and sharded runs merged into one report.