Skip to content

Keep credentials out of traces and reports; fix loading on Playwright < 1.65 - #2

Merged
jochen-testingbot merged 1 commit into
mainfrom
keep-credentials-out-of-traces
Nov 22, 2026
Merged

jochen-testingbot merged 1 commit into
mainfrom
keep-credentials-out-of-traces

Conversation

@jochen-testingbot

Copy link
Copy Markdown
Contributor

Two bugs, found while testing #1 on the grid.

1. The TestingBot secret ends up in Playwright traces and reports

The connect URL carries the key and secret, and Playwright writes it out in two places:

  • Traces, and so the HTML report: Playwright Test records the parameters of every API call, including browserType.connect. This happens on every version.
  • report.json: from 1.65 the JSON reporter writes each project's use, including connectOptions.wsEndpoint.

Both are typically uploaded as CI artifacts.

Fix:

  • withTestingBot() still sets connectOptions, but without credentials.
  • The fixtures add the credentials when they connect, inside Playwright's internal API zone (_wrapApiCall with internal), which the trace does not record. That is private API, but it behaves the same from 1.49 to 1.65; the boolean form used before 1.53 is handled too.
  • The browser fixture is replaced, so tests using browser.newContext() share the worker's session.
  • Behaviour change: a test that imports test from plain @playwright/test now fails with TestingBot's Missing key or secret instead of running. The README covers it; 0.1.0 is unreleased.

2. test did not load on Playwright older than 1.65

The context fixture asked for forcedColors and reducedMotion, which only became fixtures in 1.65. On 1.49 and 1.56 every test failed to load with Fixture "context" has unknown parameter "forcedColors", despite the >=1.49 peer range. It now takes Playwright's own merged _combinedContextOptions, which exists, test-scoped, in every supported version.

Verified on TestingBot

Chrome on Linux and Firefox on Windows 11, Playwright 1.49.1, 1.56.1 and 1.65.1, per-test and per-worker sessions:

  • All 6 runs passed, covering page with use options (viewport, locale, timezone from contextOptions) and the browser fixture.
  • None of the 28–37 output files of each run contains the key or the secret. The scan covered the traces, the html, json, junit and blob reports, and test-results.

Before this change, the secret was in the trace on every version and in report.json on 1.65.

CI

  • New compat job: lists the example's tests on Playwright 1.49.1, 1.56.1 and latest, with dummy credentials. On the old build it fails with the error above.
  • Live e2e: records traces and fails if any output contains the credentials.

- The config no longer carries the credentials in use.connectOptions:
  the JSON reporter (1.65) writes it out. The fixtures add them when
  they connect, in an internal API zone the trace does not record.
- Replace the browser fixture so it uses the worker's session.
- Take the context options from Playwright's _combinedContextOptions:
  forcedColors, reducedMotion and contrast are only fixtures since
  1.65, so test failed to load on older versions.
- CI: load the tests with Playwright 1.49.1, 1.56.1 and latest, and
  fail the live run if a report or trace contains the credentials.
@jochen-testingbot
jochen-testingbot merged commit 08f706f into main Nov 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant