File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 22 "name" : " tauri-app" ,
33 "private" : true ,
44 "version" : " 0.1.0" ,
5- "type" : " module" ,
65 "scripts" : {
76 "dev" : " vite" ,
87 "build" : " tsc && vite build" ,
1918 "devDependencies" : {
2019 "@playwright/test" : " ^1.55.1" ,
2120 "@tauri-apps/cli" : " ^2" ,
21+ "@testdriver.ai/playwright" : " ^1.0.3" ,
2222 "@types/node" : " ^24.5.2" ,
2323 "@types/react" : " ^19.1.8" ,
2424 "@types/react-dom" : " ^19.1.6" ,
Original file line number Diff line number Diff line change 1+ import type { mockIPC } from "@tauri-apps/api/mocks" ;
2+ import { expect , test } from "@testdriver.ai/playwright" ;
3+
4+ // For type-safety of the mockIPC function
5+ declare global {
6+ interface Window {
7+ mockIPC : typeof mockIPC ;
8+ }
9+ }
10+
11+ // https://tauri.app/develop/tests/mocking/#mocking-commands-for-invoke
12+ test . beforeEach ( async ( { page } ) => {
13+ await page . goto ( "http://localhost:1420" ) ;
14+ await page . evaluate ( ( ) => {
15+ window . mockIPC ( ( cmd , args ) => {
16+ switch ( cmd ) {
17+ case "greet" :
18+ args = args as { name : string } ;
19+ return `Hello, ${ args . name } ! You've been greeted from Rust!` ;
20+
21+ default :
22+ throw new Error ( `Unsupported command: ${ cmd } ` ) ;
23+ }
24+ } ) ;
25+ } ) ;
26+ } ) ;
27+
28+ test ( "should have title" , async ( { page } ) => {
29+ await expect ( page ) . toHaveTitle ( "Tauri + React + TypeScript" ) ;
30+ } ) ;
31+
32+ test ( "should have heading" , async ( { page } ) => {
33+ await expect ( page ) . toMatchPrompt ( "Heading says 'Welcome to Tauri + React'" ) ;
34+ } ) ;
35+
36+ test . describe ( "should greet with name" , ( ) => {
37+ test . agent ( `
38+ - Enter the name "Tauri"
39+ - Click the "Greet" button
40+ - You should see the text "Hello, Tauri! You've been greeted from Rust!"
41+ ` ) ;
42+ } ) ;
You can’t perform that action at this time.
0 commit comments