docs(electron): document mocking the native main-process dialog API#40952
Merged
Conversation
Adds a recipe to class-electron.md showing how to stub `dialog.showOpenDialog` / `showSaveDialog` / `showMessageBox` (and their sync variants) via `electronApplication.evaluate()`, since Playwright does not intercept the native Electron Dialog API automatically. Refs microsoft#8278
Contributor
Test results for "MCP"7181 passed, 1113 skipped Merge workflow run. |
Contributor
Test results for "tests 1"3 flaky42061 passed, 850 skipped Merge workflow run. |
dgozman
approved these changes
May 21, 2026
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
Adds a recipe to class-electron.md showing how to stub
dialog.showOpenDialog/showSaveDialog/showMessageBox(and their sync variants) viaelectronApplication.evaluate(), since Playwright doesn't intercept the native Electron Dialog API automatically.Replaces #40911.
Follow-up
If users need more sophisticated dialog interceptors with callbacks handled on the Playwright side (e.g. dynamic responses driven by test state, not just static stubs), we can later expose
ElectronApplication.exposeBinding— a main-process equivalent ofBrowserContext.exposeBinding— so the Electron main process can call into the test directly without going throughwebContents.executeJavaScript.Refs #8278