← ClaudeAtlas

testing-tauri-appslisted

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.
dchuk/claude-code-tauri-skills · ★ 21 · Testing & QA · score 58
Install: claude install-skill dchuk/claude-code-tauri-skills
# 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