Skip to content

fix(electron): enable screenshot-on-failure for Electron apps#40058

Open
Glisa060 wants to merge 1 commit intomicrosoft:mainfrom
Glisa060:fix-electron-screenshot-on-failure
Open

fix(electron): enable screenshot-on-failure for Electron apps#40058
Glisa060 wants to merge 1 commit intomicrosoft:mainfrom
Glisa060:fix-electron-screenshot-on-failure

Conversation

@Glisa060
Copy link
Copy Markdown

@Glisa060 Glisa060 commented Apr 4, 2026

Summary

  • Track Electron apps in Playwright._electronApps so _allContexts() includes Electron contexts
  • Enables screenshot: 'only-on-failure' to capture Electron windows on test failure

Update

  • Squashed two commits into one
  • Removed runAfterCreateBrowserContext call that caused tracing conflicts with Electron contexts
  • Removed playwright.artifacts.spec.ts integration test (always skipped in CI due to ELECTRON_SKIP_BINARY_DOWNLOAD=1)
  • Electron functionality is covered by 4 tests in tests/electron/electron-app.spec.ts that run in the electron CI job

@Glisa060
Copy link
Copy Markdown
Author

Glisa060 commented Apr 5, 2026

@Glisa060 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@pavelfeldman
Copy link
Copy Markdown
Member

@Glisa060 Glisa060 force-pushed the fix-electron-screenshot-on-failure branch 2 times, most recently from 01a3540 to aaff8ba Compare April 8, 2026 21:22
@Glisa060
Copy link
Copy Markdown
Author

Glisa060 commented Apr 8, 2026

Failures seem related: https://mspwblobreport.z1.web.core.windows.net/run-23988844205-2-50b5779a1623959574965456eeb37e0ca02ea02a/index.html#?q=s%3Afailed

You are right

The test-failed-1.png wasn't generated because the old code's "runAfterCreateBrowserContext" call interfered with the screenshot capture lifecycle.

After the fix (removing that call), the test passes locally. New CI run, that will be the real confirmation.

My new commit fixes the 5 failing tests in playwright.artifacts.spec.ts.
The other spec file failures are pre-existing issues and are not related to my changes

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

5 failed
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node20
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @macos-latest-node20
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node24
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node22
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @windows-latest-node20

8 flaky ⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:687 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:118 › screencast › should capture static page `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:776 › run-server › should upload a folder `@webkit-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-test-output.spec.ts:118 › should collapse repeated console messages for test `@macos-latest-node20`

39182 passed, 846 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

6468 passed, 383 skipped


Merge workflow run.

@Glisa060 Glisa060 force-pushed the fix-electron-screenshot-on-failure branch 3 times, most recently from d04f35b to d97b3ee Compare April 10, 2026 11:24
@Glisa060 Glisa060 force-pushed the fix-electron-screenshot-on-failure branch from d97b3ee to 0222c00 Compare April 10, 2026 11:24
@Glisa060
Copy link
Copy Markdown
Author

Glisa060 commented Apr 10, 2026

@pavelfeldman CI failure was due to ELECTRON_SKIP_BINARY_DOWNLOAD=1 being set in the ttest workflow — the electron binary isn't available, so _electron.launch() fails before the test logic runs. Removed the integration test from playwright.artifacts.spec.ts since it would always be skipped in that CI job. Electron functionality is covered by 4 tests in tests/electron/electron-app.spec.ts that run in the electron CI job (tests_others.yml). Could you approve the CI workflow run when you get a chance?

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.

2 participants