# Add End-to-End Tests to a Tauri App

Yes. An agent adds WebdriverIO tests driven by tauri-driver to your Tauri 2 app, builds the debug binary, runs them under Xvfb, wires a CI job, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-e2e-tests/tauri/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads both halves of the app before it writes a test. In an app laid out like Uninen/tauri-vue-template, `package.json` runs Vue 3 with Vite, `@tauri-apps/api` and `@tauri-apps/cli` 2.10, `pnpm` 10 and Node 24 in CI, and a `test` script that is `vitest`; `vitest.config.ts` includes `tests/unit/**/*.test.ts`, and the one file there asserts that `1` equals `1`. `src-tauri/Cargo.toml` depends on `tauri` 2, `tauri-plugin-shell` and `tauri-plugin-prevent-default`, with the library named `tauri_app_lib`; `src-tauri/src/lib.rs` registers a `greet` command that returns `Hello, {name}! You've been greeted from Rust!` and opens the devtools on debug builds; `tauri.conf.json` names the product `tauri-app`, serves `http://localhost:1420` in development, runs `pnpm build` before a build and bundles from `../dist`. `GreetComponent.vue` has an `#greet-input`, a submit button that calls `invoke('greet')`, and a second line from the Pinia store that reads `Greetings from Pinia store, {name}!`. `.github/workflows/test.yml` runs `pnpm test` on `ubuntu-latest`, and `test-build.yml` installs `libwebkit2gtk-4.1-dev`, `libappindicator3-dev`, `librsvg2-dev` and `patchelf` on `ubuntu-24.04` before `pnpm tauri build`.

Tauri 2 is driven through `tauri-driver`, a WebDriver proxy installed with `cargo install tauri-driver --locked`, which talks to the platform's WebView driver: `WebKitWebDriver` from the `webkit2gtk-driver` package on Debian-based Linux, `msedgedriver` on Windows. There is no WKWebView driver, so macOS cannot run this route; the agent says so up front and points at `@wdio/tauri-service` with its embedded driver as the newer option that covers all three platforms. The sandbox is Linux, so it installs `webkit2gtk-driver` and `xvfb` beside the packages the build workflow already lists, installs `tauri-driver`, and builds the app once with `pnpm tauri build --debug --no-bundle`, which leaves the binary at `src-tauri/target/debug/tauri-app`.

The tests live in an `e2e/` directory with their own `package.json`: `@wdio/cli` with `@wdio/local-runner`, `@wdio/mocha-framework` and `@wdio/spec-reporter`, and a `wdio.conf.js` that connects to `127.0.0.1` on port `4444`, declares one capability with `maxInstances: 1` and `'tauri:options': { application: '../src-tauri/target/debug/tauri-app' }`, runs the debug build in `onPrepare`, spawns `~/.cargo/bin/tauri-driver` in `beforeSession` and kills it in `afterSession` and on exit. The specs are the app's own behaviour: the `h1` reads `Welcome to Tauri 2 + Vue`; typing a name into `#greet-input` and submitting shows the Rust greeting with that name, which proves the `invoke` round trip through the real backend; and the Pinia line updates with the same name. Because the debug build opens the devtools, the agent checks that the extra window does not steal the session, and if it does, gates `open_devtools` behind an environment variable with a note in the pull request.

It runs `xvfb-run pnpm --dir e2e test` in the sandbox until the specs pass, then adds `.github/workflows/e2e.yml`: `ubuntu-24.04`, the apt packages plus `webkit2gtk-driver` and `xvfb`, `dtolnay/rust-toolchain@stable`, `Swatinem/rust-cache` with `workspaces: src-tauri`, `cargo install tauri-driver --locked`, `pnpm install` in the root and in `e2e/`, and the same `xvfb-run` command. The unit tests in `vitest` stay where they are; the pull request opens when both pass.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add end-to-end tests to this Tauri 2 app. Read package.json, vitest.config.ts, tests/unit, src/App.vue, src/components/GreetComponent.vue, src/store.ts, src-tauri/Cargo.toml, src-tauri/src/lib.rs, src-tauri/tauri.conf.json and the workflows under .github first. Install the Linux build packages the build workflow lists plus webkit2gtk-driver and xvfb, install tauri-driver with cargo install tauri-driver --locked, and build the app with pnpm tauri build --debug --no-bundle. Create an e2e directory with WebdriverIO (cli, local-runner, mocha-framework, spec-reporter) and a wdio.conf.js that connects to 127.0.0.1:4444, uses tauri:options with the debug binary path, builds in onPrepare and spawns and kills tauri-driver around each session. Write specs for the heading, the greet form's Rust round trip with a typed name, and the store line. If the debug build's devtools window interferes, gate open_devtools behind an environment variable and say so. Run xvfb-run pnpm --dir e2e test until it passes, add a GitHub Actions workflow that does the same on ubuntu-24.04 with rust-cache, and open a pull request that quotes the spec output and states that macOS is not supported by tauri-driver.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds `e2e/package.json`, `e2e/wdio.conf.js` and `e2e/specs/app.e2e.js`, adds `.github/workflows/e2e.yml`, and touches `src-tauri/src/lib.rs` only if the devtools gate was needed. Its description quotes the spec reporter output from the sandbox run, names the binary path the tests drive and the packages the workflow installs, and states plainly that the suite runs on Linux and Windows and not on macOS, with the service-based alternative named for teams that need it.

A reviewer checks the three specs against the app's behaviour, decides whether the e2e workflow should run on every pull request or only when `src/` or `src-tauri/` change (the existing workflows already use `paths` filters, and the new one copies that pattern), and confirms the `rust-cache` step keeps the job's build time acceptable.

From then on a change to a Tauri command or to the component that calls it is covered by a test that runs the real binary, which the unit tests, running in Node without a WebView, cannot do.

## Run it on every pull request that changes src-tauri

An automation on the Project with a `github` trigger on `pull_request.opened` and the prompt "if this pull request changes src-tauri or a component that calls invoke, build the debug binary, run the e2e suite under xvfb-run, and post the spec output as your review; add a spec for any new command the diff introduces" starts one run per pull request. The trigger adds the pull request after the prompt and fills in nothing else, so the run reads the diff to decide. Only work by an owner, member or collaborator fires it.

A team with several Tauri apps sends this body once per repository from its own server, each `POST /o/{org}/sessions` with that repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own app: a React front end gets specs against its own selectors, and an app with a custom window title gets that in the first spec.

## Why run it on Rush?

A Tauri end-to-end suite is mostly environment: the WebView driver package, `tauri-driver` from cargo, a virtual display, a debug build that takes minutes, and a devtools window that may or may not grab the session. The agent does all of that in its own Linux sandbox, runs the specs against the real binary, and keeps the output with the pull request, so the first green run happened before anyone on the team installed anything.

A reviewer reads three specs and a workflow rather than a setup guide, and the platform limits are written down. A team with several desktop apps starts the same request across all of them at once.

## Frequently asked questions

### Does this run on macOS?

Not through `tauri-driver`: there is no WebDriver for WKWebView, so only Linux and Windows are supported on that route. `@wdio/tauri-service` with its embedded driver provider covers macOS as well, and the pull request names it as the alternative for a team that develops on Macs.

### Why the debug build?

It is what the WebdriverIO example drives and it skips bundling, so `pnpm tauri build --debug --no-bundle` is the fastest path to a binary. The same configuration points at `target/release` for a release-build run, at the cost of a longer compile.

### What about the unit tests?

They stay in `vitest` and keep running in Node, where `invoke` does not exist. The e2e suite is the only place the Rust command is exercised, which is why the greet spec types a name and checks the exact string `lib.rs` formats.

### Will the devtools window break the tests?

The template opens devtools on debug builds. The agent runs the suite and reports what happened; if the extra window takes the session, it gates `open_devtools` behind an environment variable that the e2e configuration leaves unset, and the pull request shows the two-line change.

## More Tauri jobs

- [Add Native File Dialogs to a Tauri App](https://getrush.ai/run/add-file-dialogs/tauri/)
- [Add a Global Keyboard Shortcut to a Tauri App](https://getrush.ai/run/add-global-shortcut/tauri/)
- [Add i18n to a Tauri App](https://getrush.ai/run/add-i18n/tauri/)

## The same job on other stacks

- [Add Playwright End-to-End Tests to a Chrome Extension](https://getrush.ai/run/add-e2e-tests/chrome-extension/)

## More jobs like this: Write the missing tests

- [Add libFuzzer Fuzz Tests to a CMake Project](https://getrush.ai/run/add-fuzz-tests/cmake/)
- [Add Fuzz Tests to a Go CLI](https://getrush.ai/run/add-fuzz-tests/go-cli/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
