# Test your macOS app with e2e

> Test native macOS apps with @e2e-dev/desktop using the same agent, screen, and expect APIs as web and mobile. The app runs in the background, secrets stay out of it, and it runs about 4× faster than XCUITest and Appium.

By DongYun Kang. Published 2026-12-02. Canonical URL: https://e2e.com/blog/test-your-macos-app-with-e2e

Today we're releasing `@e2e-dev/desktop`, an e2e engine for native macOS apps.

In [our architecture deep dive](https://e2e.com/blog/write-a-test-once-run-it-anywhere), we said desktop support was coming soon. Until now, e2e tested web and mobile apps. With the desktop engine, it tests native desktop apps too: any macOS native app, whatever framework it's built with. Tests use the same `agent`, `screen`, and `expect` APIs you already use on the web and on mobile.

- [**The same test API**](#write-a-test): locators, assertions, and agent steps such as `agent.act` work as they do on every other platform
- [**Your Mac stays yours**](#your-mac-stays-yours): the app runs in the background, so your mouse and keyboard stay free while tests run
- [**Your secrets stay out of the app**](#your-secrets-stay-out-of-the-app): the app gets a minimal environment, and password fields are blacked out in screenshots
- [**Fast**](#how-fast-is-it): on the same sign-in flow, e2e ran about 4× faster than XCUITest and Appium, even with real clicks and typing

## Get started

Install the runner and the engine:

```bash
npm install --save-dev e2e @e2e-dev/desktop
```

npm installs the native driver for your Mac along with the engine. In a project with no e2e config yet, `npx e2e init --yes --engine desktop` writes the config and an example test for you.

The app that starts e2e (your terminal, your IDE, or your CI agent) needs two permissions in **System Settings > Privacy & Security**: Accessibility, to read and drive the app, and Screen Recording, for screenshots. `npx e2e doctor` checks both.

Point a target at your built `.app` bundle:

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

export default {
  targets: [
    {
      name: "mac",
      engine: desktop(),
      app: { appPath: "build/MyApp.app" },
    },
  ],
  credentials: {
    ada: { username: "ada", password: process.env.ADA_PASSWORD ?? "" },
  },
} satisfies E2EConfig;
```

## Write a test

A desktop test reads like any other e2e test:

```ts
import { test } from "@e2e-dev/desktop";
import { credentials, expect } from "e2e";

test("signs in", async ({ app, screen }) => {
  const ada = credentials.user("ada");
  await app.open();
  await screen.getByRole("textbox", "Username").fill(ada.username);
  await screen.getByRole("textbox", "Password").fill(ada.password);
  await screen.getByRole("combobox", "Plan").selectOption("Team");
  await screen.getByRole("button", "Sign in").tap();
  await expect(screen.getByTestId("status")).toContainText("Signed in as ada");
});
```

Roles use the names the web uses: `textbox`, `checkbox`, `combobox`, `button`. Agent steps work too, with the same `agent.act` you use on the web and on mobile.

The desktop engine is for native controls. It doesn't support browser windows, Electron apps, or web views. For those, use `@e2e-dev/web` for web apps and [`@e2e-dev/electron`](https://e2e.com/blog/test-your-electron-app-with-e2e) for Electron apps.

## Your Mac stays yours

By default, `app.open()` leaves the app in the background. Actions go through the macOS Accessibility API, not the real pointer and keyboard, so you can keep using your Mac while the tests run. XCUITest and Appium bring the app to the front while they run.

This matters most when you develop with AI agents. The agent runs the tests, and you keep working on the same machine.

## Your secrets stay out of the app

The app under test gets only a minimal environment, so your secrets, model keys, and CI tokens never leak into it. Password fields never expose their value, and they're painted black in screenshots. If a screenshot can't cover one, it fails instead of saving.

## How fast is it?

We ran the same sign-in flow with e2e, XCUITest, Appium Mac2, and AppleScript.

By default, e2e doesn't type. `fill` sets a field's value through the accessibility API in one step. XCUITest and Appium type key by key and send real clicks. To keep the comparison fair, we didn't use e2e's default mode. We ran it with `physicalInput: true`, which types and clicks the same way they do.

| Tool                        | One flow (median) |
| --------------------------- | ----------------- |
| **e2e** (`physicalInput`)   | **1.34 s**        |
| XCUITest                    | 5.61 s            |
| Appium Mac2                 | 5.70 s            |
| AppleScript (System Events) | 0.93 s            |

Here's where the time goes, step by step:

| Tool                        | launch     | fill       | check     | select     | submit     | quit       |
| --------------------------- | ---------- | ---------- | --------- | ---------- | ---------- | ---------- |
| **e2e** (`physicalInput`)   | **271 ms** | **324 ms** | **89 ms** | **439 ms** | **125 ms** | **103 ms** |
| XCUITest                    | 387 ms     | 1.39 s     | 559 ms    | 1.69 s     | 556 ms     | 1.04 s     |
| Appium Mac2                 | 429 ms     | 1.13 s     | 650 ms    | 1.81 s     | 641 ms     | 1.05 s     |
| AppleScript (System Events) | 270 ms     | 28 ms      | 37 ms     | 241 ms     | 144 ms     | 38 ms      |
| e2e (default)               | 274 ms     | 28 ms      | 49 ms     | 441 ms     | 127 ms     | 103 ms     |

In its default mode, e2e is faster still: 1.03 s for the same flow.

AppleScript is the floor, not a competitor. It drives the app through the same accessibility API, but it has no auto-waiting, locators, reports, or screenshots, so it isn't a realistic way to write desktop e2e tests.

This benchmark has clear limits. It's one simple AppKit form on one machine, on macOS only, and it measures speed only. The desktop engine is also still early, and we haven't started optimizing it yet. The code is [on GitHub](https://gist.github.com/kdy1/018493ab30ffaba2e92433da60097cd0) if you want to run it yourself.

## How it works

The engine reads and drives the app through the OS accessibility tree.

The architecture post described engines written in a native language that talk to e2e over JSON-RPC. The desktop engine takes a different path. Its driver is written in Rust and loaded through [napi-rs](https://napi.rs) into the test process, and the test process calls it directly. There is no separate process and no JSON-RPC between the test and the driver.

I'm DongYun Kang (kdy1), the creator of [swc](https://swc.rs). Before building swc, I researched what it takes to mix two languages in one program. Both the choice of napi-rs and the trade-offs below come from that research.

### Why not TypeScript

The engine needs a lot of native functionality, which TypeScript can't reach easily. That left two candidates: Swift and Rust.

### Why Rust over Swift

**Performance.** A Swift driver would have meant JSON-RPC between the test process and the driver, and every action, even a single tap, would pay for a round trip. We didn't profile it, but from the known cost of each IPC method, that overhead looked too high for actions as light as a tap. With Rust and napi-rs, the test process calls the driver directly.

**Memory management.** When two languages that both manage memory automatically share one program, the code that keeps the two systems in step gets very complex. gomobile's gobind, which connects Go and Java, is one example. I've used it and read the Java and Go code it generates. Rust has no GC, so there is only one to deal with.

**Safety.** napi-rs's core modules wrap almost all of the `unsafe` code that a native addon needs. Rust is a language I know well, and I'd still rather not write `unsafe` by hand.

**Ecosystem.** Many languages call into Rust for performance, so the tooling for mixing Rust with another language is far more mature than for other language pairs. That makes Rust a strong choice for any mixed-language project, and it keeps the door open to supporting other programming languages later.

### What this means for you

You don't need Rust or Xcode to use the engine. npm installs the driver for your Mac with the engine.

## Closing words

Desktop support ships today as experimental. Options and behavior can change in any release until it's stable, so pin `@e2e-dev/desktop` to an exact version. The engine runs on macOS 13 or later, and we're planning support for other desktop operating systems. The [desktop guide](https://e2e.com/docs/desktop) covers what's supported today.

Try it on your app, and if something doesn't work, [open an issue on GitHub](https://github.com/e2e-inc/e2e/issues).

```bash
npm install --save-dev e2e @e2e-dev/desktop
```
