Repository navigation
test: Playwright 1.65.0, and e2e runs that do not take focus - #17
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Playwright's new --background option is only for the MCP server in --extension mode, so it does not change _electron.launch. Instead, playwright.config.ts sets BROWSER_BACKGROUND=1, and the app then uses the 'prohibited' activation policy. Windows still open, but the app cannot become active, so a local run does not take focus. BROWSER_BACKGROUND=0 shows the app as usual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
@playwright/testfrom 1.64.1 to 1.65.0. The full e2e suite passes with no changes to the tests.pnpm test:e2edoes not take focus.Why not Playwright's
--backgroundmicrosoft/playwright#43864 is in 1.65.0, but its
--backgroundflag applies only to the Playwright MCP server in--extensionmode (Chrome with the Playwright extension). It does not changeplaywright testor_electron.launch.What changes
playwright.config.tssetsBROWSER_BACKGROUND=1if it is not set. The tests already passprocess.envto the app.BROWSER_BACKGROUND=1on macOS,electron/main.cjscallsapp.setActivationPolicy("prohibited"). The windows still open and render, but the app cannot become active. This also covers the manywindow.focus()andwebContents.focus()calls, which activate the app on macOS.BROWSER_BACKGROUND=0 pnpm test:e2eshows the app as usual, for example to watch a test.accessorypolicy did not work:focus()still activates the app.pnpm test:package) does not change. It starts the app as a user would.Test plan
tests/e2e/background.spec.ts: the window is visible, but no window has focus, also afterwindow.focus(). It failed before the change and passes after it.pnpm test:e2e: 21 passed.BROWSER_BACKGROUND=0: the background test is skipped, and the other tests pass.pnpm checkandpnpm test(162 passed).🤖 Generated with Claude Code