# Test your Electron app with e2e

> Test Electron apps with @e2e-dev/electron using the same agent, screen, and expect APIs as web and mobile, plus an electron fixture for windows, main-process evaluation, dialogs, and downloads.

By Oskar Kwasniewski. Published 2026-11-30. Canonical URL: https://e2e.com/blog/test-your-electron-app-with-e2e

Today we're releasing `@e2e-dev/electron`, an e2e engine for [Electron](https://www.electronjs.org/).

Electron is a popular framework for building desktop apps. At its core it's a web page with a lot around it. There is a main process, native menus, file dialogs, and usually more than one window. The Electron engine tests all of it with the same `agent`, `screen`, and `expect` APIs you already use on the web and on mobile.

- [**One command to set up**](#get-started): `e2e init` writes the config and a first test
- [**The same test API**](#write-a-test): locators, assertions, and agent steps work as they do on every other platform
- [**The `electron` fixture**](#interacting-with-electron-apis): switch windows, run code in the main process, answer dialogs, wait for downloads

## Get started

In a project with an Electron app, run:

```bash
npx e2e init --engine electron
```

This installs `@e2e-dev/electron` and writes a target that points at your app:

```ts title="e2e.config.ts"
import type { E2EConfig } from "e2e";
import { electron } from "@e2e-dev/electron";

export default {
  targets: [
    {
      name: "electron",
      engine: electron(),
      app: { appPath: "." },
    },
  ],
} satisfies E2EConfig;
```

The engine launches the `electron` package already installed in your project. To start from a working app instead, run `npx e2e init my-app --example with-electron`.

## Write a test

`app.open()` launches the app and waits for a window to load. From there, a test reads like any other e2e test:

```ts
import { test } from "@e2e-dev/electron";
import { expect } from "e2e";

test("greets the name you type", async ({ app, screen }) => {
  await app.open();

  await screen.getByLabel("name").fill("Ada");
  await screen.getByRole("button", "greet").click();

  await expect(screen.getByRole("status")).toHaveText("hello, Ada!");
});
```

Every test starts on an empty user-data directory and quits the app when it ends, so tests don't share state and can run in parallel.

Agent steps work too. Describe the goal, and pair it with a check that doesn't depend on the model:

```ts
test("the agent gets a greeting", async ({ app, agent, screen }) => {
  await app.open();

  await agent.act("get the app to greet {name}", { params: { name: "Grace" } });

  await expect(screen.getByRole("status")).toHaveText("hello, Grace!");
});
```

## Interacting with Electron APIs

The parts of your app that live outside the page go through the `electron` fixture.

A window the app opens doesn't become active on its own. `electron.waitForWindow()` runs the step that opens it, then points `screen` at it:

```ts
await electron.waitForWindow(() => screen.getByRole("button", "Open settings").tap());
await expect(screen.getByRole("heading", "Settings")).toBeVisible();
```

`electron.evaluate()` runs code in the main process. Use it to click a menu item or stub a native file dialog:

```ts
await electron.evaluate(({ Menu }) => {
  Menu.getApplicationMenu()?.getMenuItemById("open-settings")?.click();
});

await electron.evaluate(({ dialog }, filePath) => {
  dialog.showOpenDialog = async () => ({ canceled: false, filePaths: [filePath] });
}, "/tmp/report.csv");
```

The fixture also answers `alert` and `confirm` dialogs with `electron.onDialog()`, waits for files with `electron.waitForDownload()`, and asserts on the active window with `expect(electron).toHaveURL()` and `toHaveTitle()`.

Learn more in the [Electron engine reference](https://e2e.com/docs/reference/electron).

## How it works

The engine has no runtime dependencies and no automation library underneath. It talks with the app directly through Chrome DevTools Protocol (CDP) and reads each window through Chromium's accessibility tree.

## Closing words

Electron support ships today as experimental. Options and behavior can change in any release until it's stable, so pin `@e2e-dev/electron` to an exact version. The [Electron guide](https://e2e.com/docs/electron#limits) has the full list.

Try it today on your app:

```bash
npx e2e init --engine electron
```
