Repository navigation
Keep credentials out of traces and reports; fix loading on Playwright < 1.65 - #2
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
browserType.connect. This happens on every version.report.json: from 1.65 the JSON reporter writes each project'suse, includingconnectOptions.wsEndpoint.Both are typically uploaded as CI artifacts.
Fix:
withTestingBot()still setsconnectOptions, but without credentials._wrapApiCallwithinternal), 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.browserfixture is replaced, so tests usingbrowser.newContext()share the worker's session.testfrom plain@playwright/testnow fails with TestingBot'sMissing key or secretinstead of running. The README covers it; 0.1.0 is unreleased.2.
testdid not load on Playwright older than 1.65The
contextfixture asked forforcedColorsandreducedMotion, which only became fixtures in 1.65. On 1.49 and 1.56 every test failed to load withFixture "context" has unknown parameter "forcedColors", despite the>=1.49peer 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:
pagewithuseoptions (viewport, locale, timezone fromcontextOptions) and thebrowserfixture.Before this change, the secret was in the trace on every version and in
report.jsonon 1.65.CI
compatjob: 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.