testing-tauri-apps
Guides developers through testing Tauri applications including unit testing with mock runtime, mocking Tauri APIs, WebDriver end-to-end testing with Selenium and WebdriverIO, and CI integration with GitHub Actions.
What this skill does
# Testing Tauri Applications
This skill covers testing strategies for Tauri v2 applications: unit testing with mocks, end-to-end testing with WebDriver, and CI integration.
## Testing Approaches Overview
Tauri supports two primary testing methodologies:
1. **Unit/Integration Testing** - Uses a mock runtime without executing native webview libraries
2. **End-to-End Testing** - Uses WebDriver protocol for browser automation
## Mocking Tauri APIs
The `@tauri-apps/api/mocks` module simulates a Tauri environment during frontend testing.
### Install Mock Dependencies
```bash
npm install -D vitest @tauri-apps/api
```
### Mock IPC Commands
```javascript
import { mockIPC, clearMocks } from '@tauri-apps/api/mocks';
import { invoke } from '@tauri-apps/api/core';
import { vi, describe, it, expect, afterEach } from 'vitest';
afterEach(() => {
clearMocks();
});
describe('Tauri Commands', () => {
it('should mock the add command', async () => {
mockIPC((cmd, args) => {
if (cmd === 'add') {
return (args.a as number) + (args.b as number);
}
});
const result = await invoke('add', { a: 12, b: 15 });
expect(result).toBe(27);
});
it('should verify invoke was called', async () => {
mockIPC((cmd) => {
if (cmd === 'greet') return 'Hello!';
});
const spy = vi.spyOn(window.__TAURI_INTERNALS__, 'invoke');
await invoke('greet', { name: 'World' });
expect(spy).toHaveBeenCalled();
});
});
```
### Mock Sidecar and Shell Commands
```javascript
import { mockIPC } from '@tauri-apps/api/mocks';
mockIPC(async (cmd, args) => {
if (args.message.cmd === 'execute') {
const eventCallbackId = `_${args.message.onEventFn}`;
const eventEmitter = window[eventCallbackId];
eventEmitter({ event: 'Stdout', payload: 'process output data' });
eventEmitter({ event: 'Terminated', payload: { code: 0 } });
}
});
```
### Mock Events (v2.7.0+)
```javascript
import { mockIPC } from '@tauri-apps/api/mocks';
import { emit, listen } from '@tauri-apps/api/event';
mockIPC(() => {}, { shouldMockEvents: true });
const eventHandler = vi.fn();
await listen('test-event', eventHandler);
await emit('test-event', { foo: 'bar' });
expect(eventHandler).toHaveBeenCalled();
```
### Mock Windows
```javascript
import { mockWindows } from '@tauri-apps/api/mocks';
import { getCurrent, getAll } from '@tauri-apps/api/webviewWindow';
mockWindows('main', 'second', 'third');
// First parameter is the "current" window
expect(getCurrent()).toHaveProperty('label', 'main');
expect(getAll().map((w) => w.label)).toEqual(['main', 'second', 'third']);
```
### Vitest Configuration
```javascript
// vitest.config.js
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
environment: 'jsdom',
setupFiles: ['./test/setup.js'],
},
});
// test/setup.js
window.__TAURI_INTERNALS__ = {
invoke: vi.fn(),
transformCallback: vi.fn(),
};
```
## WebDriver End-to-End Testing
WebDriver testing uses `tauri-driver` to automate Tauri applications.
### Platform Support
| Platform | Support | Notes |
|----------|---------|-------|
| Windows | Full | Requires Microsoft Edge Driver |
| Linux | Full | Requires WebKitWebDriver |
| macOS | None | WKWebView lacks WebDriver tooling |
### Install tauri-driver
```bash
cargo install tauri-driver --locked
```
### Platform Dependencies
```bash
# Linux (Debian/Ubuntu)
sudo apt install webkit2gtk-driver xvfb
which WebKitWebDriver # Verify installation
# Windows (PowerShell)
cargo install --git https://github.com/chippers/msedgedriver-tool
& "$HOME/.cargo/bin/msedgedriver-tool.exe"
```
## WebdriverIO Setup
### Project Structure
```
my-tauri-app/
├── src-tauri/
├── src/
└── e2e-tests/
├── package.json
├── wdio.conf.js
└── specs/
└── app.spec.js
```
### Package Configuration
```json
{
"name": "tauri-e2e-tests",
"version": "1.0.0",
"type": "module",
"scripts": { "test": "wdio run wdio.conf.js" },
"dependencies": { "@wdio/cli": "^9.19.0" },
"devDependencies": {
"@wdio/local-runner": "^9.19.0",
"@wdio/mocha-framework": "^9.19.0",
"@wdio/spec-reporter": "^9.19.0"
}
}
```
### WebdriverIO Configuration
```javascript
// e2e-tests/wdio.conf.js
import { spawn, spawnSync } from 'child_process';
let tauriDriver;
export const config = {
hostname: '127.0.0.1',
port: 4444,
specs: ['./specs/**/*.js'],
maxInstances: 1,
capabilities: [{
browserName: 'wry',
'tauri:options': {
application: '../src-tauri/target/debug/my-tauri-app',
},
}],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: { ui: 'bdd', timeout: 60000 },
onPrepare: () => {
const result = spawnSync('cargo', ['build', '--manifest-path', '../src-tauri/Cargo.toml'], {
stdio: 'inherit',
});
if (result.status !== 0) throw new Error('Failed to build Tauri app');
},
beforeSession: () => {
tauriDriver = spawn('tauri-driver', [], { stdio: ['ignore', 'pipe', 'pipe'] });
return new Promise((resolve) => {
tauriDriver.stdout.on('data', (data) => {
if (data.toString().includes('listening')) resolve();
});
});
},
afterSession: () => tauriDriver?.kill(),
};
```
### WebdriverIO Test Example
```javascript
// e2e-tests/specs/app.spec.js
describe('My Tauri App', () => {
it('should display the header', async () => {
const header = await $('body > h1');
expect(await header.getText()).toMatch(/^[hH]ello/);
});
it('should interact with a button', async () => {
const button = await $('#greet-button');
await button.click();
const output = await $('#greet-output');
await output.waitForExist({ timeout: 5000 });
expect(await output.getText()).toContain('Hello');
});
});
```
## Selenium Setup
### Package Configuration
```json
{
"name": "tauri-selenium-tests",
"version": "1.0.0",
"scripts": { "test": "mocha" },
"dependencies": {
"chai": "^5.2.1",
"mocha": "^11.7.1",
"selenium-webdriver": "^4.34.0"
}
}
```
### Selenium Test Example
```javascript
// e2e-tests/test/test.js
import { spawn, spawnSync } from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';
import { Builder, By } from 'selenium-webdriver';
import { expect } from 'chai';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
let driver, tauriDriver;
const application = path.resolve(__dirname, '../../src-tauri/target/debug/my-tauri-app');
describe('Tauri App Tests', function () {
this.timeout(60000);
before(async function () {
spawnSync('cargo', ['build', '--manifest-path', '../../src-tauri/Cargo.toml'], {
cwd: __dirname, stdio: 'inherit',
});
tauriDriver = spawn('tauri-driver', [], { stdio: ['ignore', 'pipe', 'pipe'] });
await new Promise((resolve) => {
tauriDriver.stdout.on('data', (data) => {
if (data.toString().includes('listening')) resolve();
});
});
driver = await new Builder()
.usingServer('http://127.0.0.1:4444/')
.withCapabilities({ browserName: 'wry', 'tauri:options': { application } })
.build();
});
after(async function () {
await driver?.quit();
tauriDriver?.kill();
});
it('should display greeting', async function () {
const header = await driver.findElement(By.css('body > h1'));
expect(await header.getText()).to.match(/^[hH]ello/);
});
it('should click button and show output', async function () {
const button = await driver.findElement(By.id('greet-button'));
await button.click();
const output = await driver.findElement(By.id('greet-output'));
expect(await output.getText()).to.include('Hello');
});
});
```
## CI Integration with GitHub Actions
```yaml
# .github/workflows/e2e-tests.yml
name: E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on:Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.