Test Tauri Apps
Use layered tests. No single test runner proves both the renderer and native shell.
Test Layers
| Layer | Tooling | Proves | Does not prove |
|---|---|---|---|
| Rust unit tests | cargo test | Command validation, native logic, state helpers | Webview behavior, installer behavior |
| Frontend unit tests | Vitest or project runner | UI logic and typed IPC wrappers | Real Tauri runtime |
| Tauri JS mocks | mockIPC, event/window mocks | Command names, payloads, renderer error paths | Native side effects |
| Sidecar mocks | Mocked shell/sidecar events | UI handling of stdout, stderr, exit, failure | Real binary packaging |
| WebDriver | WebdriverIO Tauri service | Running app E2E behavior | Store submission or signed update trust |
| Release smoke | Installed artifact | Packaging, static assets, sidecars, config overrides | Full regression coverage |
Mock IPC Pattern
import { mockIPC } from "@tauri-apps/api/mocks";
mockIPC((cmd, args) => {
if (cmd === "load_settings") {
return { theme: "dark" };
}
throw new Error(`unexpected command: ${cmd}`);
});
Use this to keep frontend tests honest about command names and payloads.
Rust Command Tests
Extract validation and business logic into testable functions when command handlers become too coupled to Tauri runtime types.
fn validate_project_id(value: &str) -> bool {
!value.is_empty() && value.chars().all(|ch| ch.is_ascii_alphanumeric() || ch == '_')
}
#[test]
fn rejects_path_like_project_id() {
assert!(!validate_project_id("../secret"));
}
WebDriver Smoke
Use WebDriver for a running app smoke path when UI behavior depends on the real shell. The Tauri docs recommend WebdriverIO with the Tauri service and note that direct tauri-driver has platform limits.
Smoke at least:
app launches
main window loads built frontend
one command-backed flow works
one denied/invalid permission path behaves safely
logs contain no secrets
app exits and sidecars clean up
Platform Matrix
| Platform | Minimum proof |
|---|---|
| Windows | Release artifact plus WebView2 install/runtime note |
| macOS | App launches, signing/notarization state recorded |
| Linux | Distro/WebKitGTK prerequisites recorded and app launches |
| Android | APK/AAB build plus emulator or device smoke |
| iOS | Xcode/iOS build plus simulator or device smoke |