testdriverai 6.1.1-canary.a2e60e2.0 → 6.1.1-canary.df0c552.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/docs.json CHANGED
@@ -64,8 +64,7 @@
64
64
  "apps/static-websites",
65
65
  "apps/desktop-apps",
66
66
  "apps/chrome-extensions",
67
- "apps/mobile-apps",
68
- "apps/tauri-apps"
67
+ "apps/mobile-apps"
69
68
  ]
70
69
  },
71
70
  {
package/docs/styles.css CHANGED
@@ -53,13 +53,4 @@
53
53
  transform: translateX(-50%);
54
54
  justify-content: center;
55
55
  display: flex;
56
- }
57
-
58
- img[src$=".svg"] {
59
- background: transparent !important;
60
- }
61
-
62
- img[src$="https://tauri.app/favicon.svg"]
63
- {
64
- opacity: 0.3;
65
- }
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "6.1.1-canary.a2e60e2.0",
3
+ "version": "6.1.1-canary.df0c552.0",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,403 +0,0 @@
1
- ---
2
- title: "Tauri Apps"
3
- sidebarTitle: "Tauri Apps"
4
- description: "Testing Tauri Apps with TestDriver"
5
- icon: "https://tauri.app/favicon.svg"
6
- ---
7
-
8
- > [Tauri](https://tauri.app/) is a framework for building tiny, fast binaries for all major desktop and mobile platforms. Developers can integrate any frontend framework that compiles to HTML, JavaScript, and CSS for building their user experience while leveraging languages such as Rust, Swift, and Kotlin for backend logic when needed.
9
- >
10
- > <br />– [https://tauri.app/start](https://tauri.app/start/)
11
-
12
- ## Testing Tauri apps with TestDriver
13
-
14
- In this guide, we'll leverage [Playwright](https://playwright.dev/) and the
15
- [TestDriver Playwright SDK](/getting-started/playwright) to convert the [Tauri Quick Start](https://tauri.app/start/create-project/)
16
- to TestDriver's selectorless, Vision AI.
17
-
18
- <Callout icon="code">
19
- View Source:
20
- [https://github.com/testdriverai/demo-tauri-app](https://github.com/testdriverai/demo-tauri-app)
21
- </Callout>
22
-
23
- ### Requirements
24
-
25
- To start testing your Tauri app with TestDriver, you need the following:
26
-
27
- <AccordionGroup>
28
- <Accordion title="Create a TestDriver account">
29
- <Steps>
30
- <Step title="Create a TestDriver Account">
31
- You will need a [TestDriver Pro](https://app.testdriver.ai/team) account (\$20/month) to get an API key.
32
- <Card title="Sign Up for TestDriver" icon="user-plus" horizontal href="https://app.testdriver.ai/team" />
33
- </Step>
34
- <Step title="Set up your environment">
35
- Copy your API key from [the TestDriver dashboard](https://app.testdriver.ai/team), and set it as an environment variable.
36
-
37
- <Tabs>
38
- <Tab title="macOS / Linux">
39
- Export an environment variable on macOS or Linux systems:
40
-
41
- ```bash
42
- export TD_API_KEY="your_api_key_here"
43
- ```
44
- </Tab>
45
- <Tab title="Windows">
46
- Export an environment variable in PowerShell:
47
-
48
- ```powershell
49
- setx TD_API_KEY "your_api_key_here"
50
- ```
51
- </Tab>
52
- </Tabs>
53
- </Step>
54
-
55
- </Steps>
56
-
57
- </Accordion>
58
-
59
- <Accordion title="Install the TestDriver Playwright SDK">
60
- `@testdriver.ai/playwright` is an AI-powered extension of `@playwright/test`.
61
-
62
- <Tabs>
63
- <Tab title="npm">
64
- ```bash
65
- npm install @testdriver.ai/playwright
66
- ```
67
- </Tab>
68
- <Tab title="yarn">
69
- ```bash
70
- yarn add @testdriver.ai/playwright
71
- ```
72
- </Tab>
73
- <Tab title="pnpm">
74
- ```bash
75
- pnpm add @testdriver.ai/playwright
76
- ```
77
- </Tab>
78
- </Tabs>
79
-
80
- </Accordion>
81
-
82
- <Accordion title="Create a Playwright project">
83
- <Info>
84
- This is a condensed version of [Playwright's Installation Instructions](https://playwright.dev/docs/intro).
85
-
86
- **If you're new to Playwright, you should follow their guide first.**
87
- </Info>
88
-
89
- In a new folder or an existing directory, run:
90
-
91
- <Tabs>
92
- <Tab title="npm">
93
- ```bash
94
- npm init playwright@latest
95
- ```
96
- </Tab>
97
- <Tab title="yarn">
98
- ```bash
99
- yarn create playwright
100
- ```
101
- </Tab>
102
- <Tab title="pnpm">
103
- ```bash
104
- pnpm create playwright
105
- ```
106
- </Tab>
107
- </Tabs>
108
- Select the following options when prompted:
109
-
110
- ```console
111
- ✔ Do you want to use TypeScript or JavaScript?
112
- > TypeScript
113
- ✔ Where to put your end-to-end tests?
114
- > tests
115
- ✔ Add a GitHub Actions workflow? (y/N)
116
- > N
117
- ✔ Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n)
118
- > Y
119
- ```
120
-
121
- </Accordion>
122
- </AccordionGroup>
123
-
124
- ## Testing the Tauri Web App
125
-
126
- ### Setup
127
-
128
- First, we need to modify the default Playwright configuration and our Tauri project to work together:
129
-
130
- <Steps>
131
- <Step title="Configure Playwright to start the Tauri frontend">
132
-
133
- In the `playwright.config.ts` file, we'll configure the [`webServer`](https://playwright.dev/docs/test-webserver)
134
- to start the Tauri frontend for Playwright to test against:
135
-
136
- ```typescript playwright.config.ts
137
- /* Run your local dev server before starting the tests */
138
- // [!code ++:8]
139
- webServer: {
140
- command: "npm run dev",
141
- url: "http://localhost:1420",
142
- reuseExistingServer: !process.env.CI,
143
- env: {
144
- VITE_PLAYWRIGHT: "true",
145
- },
146
- },
147
- });
148
- ```
149
-
150
- </Step>
151
-
152
- <Step title="Mock Tauri APIs">
153
-
154
- Since we're testing the Tauri frontend, we need to [mock IPC Requests](https://tauri.app/develop/tests/mocking/)
155
- to simulate `invoke` calls to the Rust backend:
156
-
157
- ```html src/index.html
158
- <body>
159
- <div id="root"></div>
160
- <!-- [!code ++:7] -->
161
- <script type="module">
162
- // This is set in playwright.config.ts to allow our tests to mock Tauri IPC `invoke` calls
163
- if (import.meta.env.VITE_PLAYWRIGHT) {
164
- const { mockIPC } = await import("@tauri-apps/api/mocks");
165
- window.mockIPC = mockIPC;
166
- }
167
- </script>
168
- <script type="module" src="/src/main.tsx"></script>
169
- </body>
170
- ```
171
-
172
- We only need to do this once, as we'll be accessing `window.mockIPC` in our tests.
173
-
174
- </Step>
175
-
176
- <Step title="Create a new test file">
177
- Create a new file (e.g. `tests/testdriver.spec.ts`) with:
178
-
179
- ```typescript tests/testdriver.spec.ts
180
- import type { mockIPC } from "@tauri-apps/api/mocks";
181
- import { expect, test } from "@playwright/test";
182
-
183
- test.beforeEach(async ({ page }) => {
184
- await page.goto("http://localhost:1420");
185
- });
186
-
187
- test("should have title", async ({ page }) => {
188
- await expect(page).toHaveTitle("Tauri + React + TypeScript");
189
- });
190
- ```
191
-
192
- </Step>
193
-
194
- <Step title="Run Playwright in UI Mode">
195
-
196
- Now we're ready to run Playwright and start working on our tests:
197
-
198
- <Tabs>
199
- <Tab title="npm">
200
-
201
- ```bash
202
- npx playwright test --ui
203
- ```
204
-
205
- </Tab>
206
- <Tab title="yarn">
207
-
208
- ```bash
209
- yarn playwright test --ui
210
- ```
211
-
212
- </Tab>
213
- <Tab title="pnpm">
214
-
215
- ```bash
216
- pnpm exec playwright test --ui
217
- ```
218
-
219
- </Tab>
220
- </Tabs>
221
-
222
- ![Playwright UI Mode](https://playwright.dev/assets/ideal-img/ui-mode.4e54d6b.3598.png)
223
-
224
- Click the <Icon icon="play" /> button to successfully run the tests in the UI.
225
-
226
- <Tip>
227
- Click the <Icon icon="eye" /> button to automatically re-run tests on save.
228
- </Tip>
229
-
230
- </Step>
231
-
232
- </Steps>
233
-
234
- ### Usage
235
-
236
- #### Import the TestDriver Playwright SDK
237
-
238
- By changing **1 line**, we can add TestDriver's AI capabilities to Playwright:
239
-
240
- ```typescript tests/testdriver.spec.ts
241
- import type { mockIPC } from "@tauri-apps/api/mocks";
242
- // [!code --]
243
- import { expect, test } from "@playwright/test";
244
- // [!code ++]
245
- import { expect, test } from "@testdriver.ai/playwright";
246
-
247
- // For type-safety of the mockIPC function
248
- declare global {
249
- interface Window {
250
- mockIPC: typeof mockIPC;
251
- }
252
- }
253
-
254
- test.beforeEach(async ({ page }) => {
255
- await page.goto("http://localhost:1420");
256
- });
257
-
258
- test("should have title", async ({ page }) => {
259
- await expect(page).toHaveTitle("Tauri + React + TypeScript");
260
- });
261
- ```
262
-
263
- Notice how we're able to continue using Playwright's API (`toHaveTitle`)
264
- with `@testdriver.ai/playwright`.
265
-
266
- The test continues to pass as before, so now we can update our test to use natural language instead of selectors.
267
-
268
- #### Assertions with `expect.toMatchPrompt`
269
-
270
- With Playwright, we would normally use a `getByRole` selector to assert the heading text:
271
-
272
- ```typescript tests/example.spec.ts
273
- test("should have heading", async ({ page }) => {
274
- await expect(
275
- page.getByRole("heading", { name: "Installation" }),
276
- ).toBeVisible();
277
- });
278
- ```
279
-
280
- With TestDriver, we can use natural language with `toMatchPrompt` instead:
281
-
282
- ```typescript tests/testdriver.spec.ts
283
- test("should have heading", async ({ page }) => {
284
- // [!code --:3]
285
- await expect(
286
- page.getByRole("heading", { name: "Installation" }),
287
- ).toBeVisible();
288
- // [!code ++:1]
289
- await expect(page).toMatchPrompt("Heading says 'Welcome to Tauri + React'");
290
- });
291
- ```
292
-
293
- #### Agentic tests with `test.agent`
294
-
295
- With TestDriver, we can skip the test implementation **entirely** and let AI perform the test for us:
296
-
297
- <Steps>
298
- <Step title="Mock the `greet` call">
299
-
300
- First, we need to [mock our `invoke` calls](https://tauri.app/develop/tests/mocking/#ipc-requests),
301
- since we're testing the frontend behavior and not our Tauri backend:
302
-
303
- ```typescript tests/testdriver.spec.ts
304
- test.beforeEach(async ({ page }) => {
305
- await page.goto("http://localhost:1420");
306
- // [!code ++:12]
307
- await page.evaluate(() => {
308
- // https://tauri.app/develop/tests/mocking/#mocking-commands-for-invoke
309
- window.mockIPC((cmd, args) => {
310
- switch (cmd) {
311
- case "greet":
312
- args = args as { name: string };
313
- return `Hello, ${args.name}! You've been greeted from Rust!`;
314
- default:
315
- throw new Error(`Unsupported command: ${cmd}`);
316
- }
317
- });
318
- });
319
- });
320
- ```
321
-
322
- </Step>
323
-
324
- <Step title="Add an Agentic Test">
325
-
326
- Next, wrap a _prompt_ in `test.agent` to perform the test:
327
-
328
- ```typescript tests/testdriver.spec.ts
329
- test.describe("should greet with name", () => {
330
- test.agent(`
331
- - Enter the name "Tauri"
332
- - Click the "Greet" button
333
- - You should see the text "Hello, Tauri! You've been greeted from Rust!"
334
- `);
335
- });
336
- ```
337
-
338
- </Step>
339
- </Steps>
340
-
341
- #### Continued Reading
342
-
343
- [Learn more about TestDriver's Playwright SDK](/getting-started/playwright)
344
-
345
- ## Testing the Tauri Desktop App
346
-
347
- We can use TestDriver and natural language to test our Tauri desktop app:
348
-
349
- <Steps>
350
- <Step title="Run the Desktop App">
351
- <Tabs>
352
- <Tab title="npm">
353
- ```bash
354
- npm run tauri dev
355
- ```
356
- </Tab>
357
- <Tab title="yarn">
358
- ```bash
359
- yarn tauri dev
360
- ```
361
- </Tab>
362
- <Tab title="pnpm">
363
- ```bash
364
- pnpm tauri dev
365
- ```
366
- </Tab>
367
- </Tabs>
368
- </Step>
369
-
370
- <Step title="Continued Reading">
371
- <Note>See [Desktop Apps](/apps/desktop-apps) for more information.</Note>
372
- </Step>
373
- </Steps>
374
-
375
- ## Testing the Tauri Mobile App
376
-
377
- We can use TestDriver and natural language to test our Tauri iOS app:
378
-
379
- <Steps>
380
- <Step title="Run the Mobile App">
381
- <Tabs>
382
- <Tab title="npm">
383
- ```bash
384
- npm run tauri ios dev
385
- ```
386
- </Tab>
387
- <Tab title="yarn">
388
- ```bash
389
- yarn tauri ios dev
390
- ```
391
- </Tab>
392
- <Tab title="pnpm">
393
- ```bash
394
- pnpm tauri ios dev
395
- ```
396
- </Tab>
397
- </Tabs>
398
- </Step>
399
-
400
- <Step title="Continued Reading">
401
- <Note>See [Mobile Apps](/apps/mobile-apps) for more information.</Note>
402
- </Step>
403
- </Steps>