Skip to content

test: Playwright 1.65.0, and e2e runs that do not take focus - #17

Merged
narze merged 2 commits into
mainfrom
chore/playwright-1.65
Nov 6, 2026
Merged

narze merged 2 commits into
mainfrom
chore/playwright-1.65

Conversation

@narze

@narze narze commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Update @playwright/test from 1.64.1 to 1.65.0. The full e2e suite passes with no changes to the tests.
  • Run the e2e tests in the background on macOS, so a local pnpm test:e2e does not take focus.

Why not Playwright's --background

microsoft/playwright#43864 is in 1.65.0, but its --background flag applies only to the Playwright MCP server in --extension mode (Chrome with the Playwright extension). It does not change playwright test or _electron.launch.

What changes

  • playwright.config.ts sets BROWSER_BACKGROUND=1 if it is not set. The tests already pass process.env to the app.
  • With BROWSER_BACKGROUND=1 on macOS, electron/main.cjs calls app.setActivationPolicy("prohibited"). The windows still open and render, but the app cannot become active. This also covers the many window.focus() and webContents.focus() calls, which activate the app on macOS.
  • BROWSER_BACKGROUND=0 pnpm test:e2e shows the app as usual, for example to watch a test.
  • The accessory policy did not work: focus() still activates the app.
  • The packaged app test (pnpm test:package) does not change. It starts the app as a user would.

Test plan

  • New tests/e2e/background.spec.ts: the window is visible, but no window has focus, also after window.focus(). It failed before the change and passes after it.
  • pnpm test:e2e: 21 passed.
  • I recorded the frontmost macOS app during the runs. Before: "Electron" took focus at every launch. After: the terminal stayed frontmost for the full run.
  • BROWSER_BACKGROUND=0: the background test is skipped, and the other tests pass.
  • pnpm check and pnpm test (162 passed).

🤖 Generated with Claude Code

narze and others added 2 commits November 6, 2026 14:24
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>
@narze
narze merged commit d4a6c6e into main Nov 6, 2026
@narze
narze deleted the chore/playwright-1.65 branch November 6, 2026 07:39
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