# Write a test once, run it anywhere: a deep dive into e2e architecture

> How e2e runs one test suite on web, iOS, Android, and TVs. A test runner, a shared engine interface, an engine package per platform, and a JSON-RPC protocol for engines in any language.

By Oskar Kwasniewski. Published 2026-11-25. Canonical URL: https://e2e.com/blog/write-a-test-once-run-it-anywhere

Testing an app across web, mobile, and desktop often means maintaining separate frameworks, test suites, and workflows. We built [e2e](https://e2e.com/) to make it possible to test across platforms with one framework, without turning the framework itself into a monolith.

The key is an engine interface shared across platforms. The test runner knows how to test a UI, but it doesn't need to know exactly what platform it's driving.

## How the architecture works

e2e is split into two main pieces: the `e2e` test runner and [`@e2e-dev/core`](https://e2e.com/docs/core).

The test runner handles your tests. e2e core defines how e2e interacts with an abstract engine. Each platform [engine](https://e2e.com/docs/engines) implements that shared interface, allowing the runner to drive different platforms through the same codebase.

![The e2e test runner on top of @e2e-dev/core, the engine interface, with the web, mobile, and desktop engines and your own engine below it](https://e2e.com/blog/screenshots/e2e-architecture-architecture.webp)

That separation lets us support [web](https://e2e.com/docs/web) and [mobile](https://e2e.com/docs/mobile) today, with desktop support coming soon. It also means the architecture isn't limited to the platforms we ship. You can modify an engine or [build your own](https://e2e.com/docs/writing-an-engine) to test another kind of UI.

For example, e2e can already test TVs, as well as iOS and Android apps, and web apps. Electron and other desktop apps are coming soon. The framework stays the same; the engine handles the platform-specific interaction.

An additional benefit of separating e2e-core from the test runner is that you can use it on its own. That opens up use cases beyond testing, including scripting, scraping, and automation.

Here is a complete script that reads the post titles from our blog. There is no config file and no test runner, only an engine and a session:

```ts
import { launch } from "@e2e-dev/core";
import { web } from "@e2e-dev/web/engine";

const site = await launch(web(), { app: { url: "https://e2e.com" } });
try {
  const session = await site.newSession();
  await session.app.open("/blog");

  const posts = await session.screen.getByRole("heading", { level: 3 }).allTextContents();
  console.log(posts);
} finally {
  await site.close();
}
```

Run it with `node titles.ts`. Swap in the mobile engine and a mobile app, and the same `screen` calls drive an app on a simulator.

## Learning from React Native

This design was heavily inspired by my work as a React Native core contributor. I worked on separating React Native for visionOS into an external, or "out-of-tree," platform.

React Native doesn't have a first-class concept of out-of-tree platforms (although I heard they are working on this right now). iOS and Android were the first-party platforms, while React Native Web was added on top. Other platforms, such as visionOS, Windows, and macOS, often relied on patches or soft forks of React Native. This is less than ideal as there's a lot of maintenance burden, and the out-of-tree packages do not receive the same level of integration with core.

We wanted to avoid that distinction in e2e. Every platform is treated equally, including the platforms we build ourselves. Our first-party engines ship as separate packages, which is why you install a platform package alongside e2e.

![React Native core holds iOS and Android while web, Windows, and macOS live out of tree; @e2e-dev/core holds no platform, and web, mobile, desktop, and your engine are all packages](https://e2e.com/blog/screenshots/e2e-architecture-out-of-tree.webp)

That gives us more flexibility to add and evolve platforms, and it gives others a way to build their own engines without changing the core framework.

## Engines in native languages

![e2e in TypeScript exchanging initialize and engine/perform messages with an engine server written in any language](https://e2e.com/blog/screenshots/e2e-architecture-engine-protocol.webp)

An engine doesn't have to be written in TypeScript. e2e can communicate with a native [engine server](https://e2e.com/docs/engine-servers) over [JSON-RPC](https://e2e.com/docs/reference/engine-protocol), so you could write an engine in Rust or another native language and connect it to the framework.

This lets you keep your tests in TypeScript while implementing the engine in a language suited to its platform.

## Underlying tools

Today, our engines use existing tools to interact with platforms. For example, we use [Agent Device](https://agent-device.dev/) to talk to mobile devices and Playwright Core for web.

We're moving the web engine toward WebDriver BiDi. We'll cover that transition in a separate post.

## Sharing tests across platforms

The shared engine interface also gives teams flexibility in how they write tests.

If a test doesn't depend on platform-specific behavior, you can share it across platforms. You can also [restrict a test to a particular platform](https://e2e.com/docs/reference/test#platforms), such as web, or use conditional logic inside a shared test when an interaction differs between web and mobile. [Platform-specific tools](https://e2e.com/docs/fixtures) are available when you need them.

One config lists a target per platform:

```ts
import type { E2EConfig } from "e2e";
import { mobile } from "@e2e-dev/mobile";
import { web } from "@e2e-dev/web";

// linkBase is what lets a test open a path such as "/checkout" in the mobile app.
const shop = { bundleId: "com.example.shop", linkBase: "shop://" };

export default {
  targets: [
    { name: "web", engine: web(), app: { url: "http://localhost:3000" } },
    { name: "iphone", engine: mobile({ platform: "ios" }), app: shop },
    { name: "pixel", engine: mobile({ platform: "android" }), app: shop },
  ],
} as const satisfies E2EConfig;
```

The first test below runs on all three. `platform` says which target is running, and the fixtures are typed to match: [`browser`](https://e2e.com/docs/browser) exists only on web, so the code inside the check compiles and the same call outside it does not. The second test runs on iOS only, and the other targets skip it.

```ts
import { expect, test as base } from "e2e";
import type config from "../e2e.config.ts";

const test = base.extend<{}, {}, typeof config>();

test("adds an item to the cart", async ({ app, screen, platform, browser }) => {
  // Only the web engine has a browser, so only the web run can mock the API.
  if (platform === "web") {
    await browser.route("**/api/stock", (route) => route.fulfill({ json: { left: 1 } }));
  }

  await app.open("/products/A-1001");
  await expect(screen.getByText("Only 1 left")).toBeVisible();
  await screen.getByRole("button", "Add to cart").tap();
  await expect(screen.getByText("1 item")).toBeVisible();

  if (platform === "web") {
    await expect(browser).toHaveURL("/products/A-1001?added=1");
  }
});

test("pays with Face ID", { platforms: ["ios"] }, async ({ app, device, screen }) => {
  await app.open("/checkout");
  await screen.getByRole("button", "Pay").tap();
  await device.setBiometrics("faceid", "match");
  await expect(screen.getByText("Order placed")).toBeVisible();
});
```

One command runs the suite on every target, and `--target` picks some of them:

```bash
npx e2e run
npx e2e run --target web,iphone
```

The result is a way to unify your testing stack across the team while still accommodating the differences between platforms. And as desktop support arrives, that same approach will extend to desktop apps too.

Thanks for reading. To try e2e in your own project, run:

```bash
npx e2e init
```
