feat(examples): add with-electron (ENG-1585)
Merged
KA
19h ago+575+575+012345678901234567890123456789-17-17-01234567890123456789
What
examples/with-electron: the greeting app every example shares, built as a plain Electron app (no bundler) and tested with @e2e-dev/electron. It has three locator tests and two agent tests. npx e2e init my-app --example with-electron copies it, e2e.com/examples lists it, and the examples nightly runs it on Linux.
Why
Electron is the one engine with no example to start from. Every other platform has a with-* app.
How it works
- The app:
examples/with-electron/main.jsopens one window onsrc/index.html.src/renderer.jsdoes the greeting with plain DOM, and the markup, styles, and copy matchwith-vite.e2e.config.tssetsengine: electron()withapp: { appPath: '.' }. The tests are thewith-vitetests, importingtestfrom@e2e-dev/electronand callingapp.open()with no path. - Versions: the example pins the versions the pending changesets will publish,
e2e^0.26.0and@e2e-dev/electron0.0.1. npm has only a placeholder@e2e-dev/electron0.0.0, so this should merge with or after that release. Until then,npm installin the example fails. - The registry and init: an entry in
examples/examples.jsonwith an Electron icon inexamples/icons/anddocs/images/examples/. The icon is the Simple Icons mark, recolored to the light cyan of Electron's logo so it shows on the dark site. Awith-electronpreset inpackages/e2e/src/cli/init/examples.tsand a changeset for it. - The nightly:
.github/workflows/examples.ymlpacks@e2e-dev/electron, and.github/actions/example-packagesswaps it in like the other engines. A newdesktopjob installs Chromium's system packages (Xvfb included) with theplaywright-coreversion@e2e-dev/webpins, downloads the Electron binary with theelectronpackage'sinstall.jsbefore the model key is in the environment, then runs the suite underxvfb-run.scripts/examples-nightly/knows thedesktopplatform for the Slack summary. - Docs: a card on
docs/example-projects.mdx, the new name in theinit --examplelist indocs/reference/cli.mdx, and a pointer to the example from the setup section ofdocs/electron.mdx. The CLI reference used to say only@e2e-dev/weband@e2e-dev/mobileget init's ranges; it now says the@e2e-dev/*packages, sinceadaptManifestrewrites every recorded sibling.
Verified
Ran it locally: yes
- Built
@e2e-dev/core,e2e, and@e2e-dev/electronfrom this branch, packed them, and installed the example in a scratch copy with the tarballs swapped in, the way the nightly does. macOS 26, Node 24, Electron 45.5.0. npx tsc --noEmitpasses.npx e2e rundownloaded the Electron binary and passed the three locator tests. WithAI_GATEWAY_API_KEYset, the two agent tests passed too:
✓ |electron| tests/deterministic.e2e.ts > shows the greeting form 2.00s
✓ |electron| tests/deterministic.e2e.ts > asks for a name when the field is empty 389ms
✓ |electron| tests/deterministic.e2e.ts > greets the name you type 390ms
✓ |electron| tests/agentic.e2e.ts > the agent gets a greeting 5.51s ai 17.1k tokens · 61% cached · $0.0019
✓ |electron| tests/agentic.e2e.ts > the agent finds the empty-name error 5.02s ai 17.3k tokens · 89% cached · $0.0010
- The screenshot above is
app.screenshot()from that run. - The built CLI lists the preset:
e2e init x --example --yesnameswith-electronamong the choices. I couldn't try the copy itself, since it downloads the folder from GitHub, where it doesn't exist until this merges. - Not run: the new nightly
desktopjob (it runs only on the schedule or a manual run), Linux, and Windows. No docs screenshots: the site renders from another repository.pnpm checkandpnpm docs:checkpass.
Summary by CodeRabbit
- New Features
- Added a cross-platform Electron desktop example featuring a greeting form and end-to-end tests.
- Added
with-electronto project initialization examples, with guidance for creating a new project and running tests.
- Documentation
- Updated the examples catalog and platform support information to include Electron, including its experimental status.
- Chores
- Added the Electron example to nightly testing and reporting, including desktop test results.