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.

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
testRunIdstrgeneratedUse 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:

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_KEY—API key (required for cloud upload)
TESTRELIC_CLOUD_ENDPOINThttps://platform.testrelic.ai/api/v1Cloud endpoint override
TESTRELIC_UPLOAD_STRATEGYbatchrealtime, batch, or both
TESTRELIC_CLOUD_TIMEOUT30000Upload request timeout (milliseconds)
TESTRELIC_RUN_TYPE—Dashboard bucket: smoke, regression, nightly, or ci
TESTRELIC_CLOUD_PLATFORMauto-detectedLabel 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:

.testrelic/testrelic-config.json
{
  "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-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).

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 openReport auto-open applies; inside CI it is skipped.

Next steps

Was this page helpful?

On this page