testdriverai 6.1.10 → 6.2.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/.github/workflows/acceptance-tests.yml +0 -2
- package/.github/workflows/acceptance-v6.yml +0 -2
- package/.github/workflows/lint.yml +1 -4
- package/.github/workflows/publish-canary.yml +0 -2
- package/.github/workflows/publish-latest.yml +0 -1
- package/.prettierignore +0 -1
- package/.vscode/settings.json +1 -4
- package/agent/events.js +10 -1
- package/agent/index.js +76 -104
- package/agent/interface.js +6 -43
- package/agent/lib/censorship.js +10 -15
- package/agent/lib/commander.js +18 -31
- package/agent/lib/commands.js +63 -81
- package/agent/lib/debugger-server.js +5 -0
- package/agent/lib/generator.js +2 -2
- package/agent/lib/redraw.js +1 -0
- package/agent/lib/sandbox.js +2 -0
- package/agent/lib/sdk.js +1 -2
- package/agent/lib/source-mapper.js +1 -1
- package/agent/lib/system.js +6 -1
- package/docs/account/enterprise.mdx +12 -8
- package/docs/account/pricing.mdx +2 -2
- package/docs/account/projects.mdx +0 -5
- package/docs/cli/overview.mdx +6 -6
- package/docs/commands/assert.mdx +0 -1
- package/docs/commands/hover-text.mdx +1 -3
- package/docs/commands/match-image.mdx +4 -5
- package/docs/commands/press-keys.mdx +8 -6
- package/docs/commands/scroll-until-image.mdx +7 -8
- package/docs/commands/scroll-until-text.mdx +6 -7
- package/docs/commands/wait-for-image.mdx +4 -5
- package/docs/commands/wait-for-text.mdx +5 -6
- package/docs/docs.json +40 -42
- package/docs/getting-started/vscode.mdx +56 -67
- package/docs/guide/environment-variables.mdx +5 -5
- package/docs/overview/comparison.mdx +39 -22
- package/docs/overview/quickstart.mdx +32 -84
- package/docs/styles.css +1 -10
- package/interfaces/cli/lib/base.js +6 -27
- package/interfaces/cli/utils/factory.js +4 -17
- package/interfaces/logger.js +5 -4
- package/interfaces/readline.js +1 -1
- package/package.json +3 -3
- package/schema.json +2 -22
- package/testdriver/acceptance/hover-text.yaml +1 -2
- package/testdriver/acceptance/prompt.yaml +1 -4
- package/testdriver/acceptance/scroll-until-image.yaml +0 -5
- package/testdriver/{lifecycle/prerun.yaml → examples/web/lifecycle/provision.yaml} +0 -6
- package/testdriver/lifecycle/provision.yaml +20 -0
- package/.github/workflows/self-hosted.yml +0 -102
- package/docs/apps/tauri-apps.mdx +0 -361
- package/docs/getting-started/playwright.mdx +0 -342
- package/docs/getting-started/self-hosting.mdx +0 -370
- package/docs/guide/dashcam.mdx +0 -118
- package/docs/images/content/self-hosted/launchtemplateid.png +0 -0
- package/docs/images/content/vscode/ide-full.png +0 -0
- package/docs/images/content/vscode/running.png +0 -0
- package/interfaces/cli/commands/generate.js +0 -3
- package/setup/aws/cloudformation.yaml +0 -463
- package/setup/aws/spawn-runner.sh +0 -190
- package/testdriver/edge-cases/js-exception.yaml +0 -8
- package/testdriver/edge-cases/js-promise.yaml +0 -19
- package/testdriver/edge-cases/lifecycle/postrun.yaml +0 -10
- package/testdriver/edge-cases/success-test.yaml +0 -9
- package/testdriver/examples/web/lifecycle/postrun.yaml +0 -7
- package/testdriver/examples/web/lifecycle/prerun.yaml +0 -17
- package/testdriver/lifecycle/postrun.yaml +0 -7
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
name: AWS
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
push:
|
|
6
|
-
paths-ignore:
|
|
7
|
-
- "docs/**"
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
gather:
|
|
11
|
-
name: Gather Test Files
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
outputs:
|
|
14
|
-
test_files: ${{ steps.test_list.outputs.files }}
|
|
15
|
-
steps:
|
|
16
|
-
- name: Check out repository
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Find all test files
|
|
20
|
-
id: test_list
|
|
21
|
-
run: |
|
|
22
|
-
FILES=$(ls ./testdriver/acceptance/*.yaml)
|
|
23
|
-
FILENAMES=$(basename -a $FILES)
|
|
24
|
-
FILES_JSON=$(echo "$FILENAMES" | jq -R -s -c 'split("\n")[:-1]')
|
|
25
|
-
echo "files=$FILES_JSON" >> $GITHUB_OUTPUT
|
|
26
|
-
|
|
27
|
-
test:
|
|
28
|
-
needs: gather
|
|
29
|
-
runs-on: ubuntu-latest
|
|
30
|
-
strategy:
|
|
31
|
-
matrix:
|
|
32
|
-
test: ${{ fromJson(needs.gather.outputs.test_files) }}
|
|
33
|
-
fail-fast: false
|
|
34
|
-
steps:
|
|
35
|
-
- name: Checkout repository
|
|
36
|
-
uses: actions/checkout@v4
|
|
37
|
-
with:
|
|
38
|
-
fetch-depth: 0
|
|
39
|
-
# only needed for `act`
|
|
40
|
-
# - name: Install AWS CLI
|
|
41
|
-
# run: |
|
|
42
|
-
# apt-get update
|
|
43
|
-
# apt-get install curl unzip -y
|
|
44
|
-
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
|
45
|
-
# unzip awscliv2.zip
|
|
46
|
-
# ./aws/install
|
|
47
|
-
- name: Set up Node.js
|
|
48
|
-
uses: actions/setup-node@v4
|
|
49
|
-
with:
|
|
50
|
-
node-version: "20"
|
|
51
|
-
cache: "npm"
|
|
52
|
-
- name: Install dependencies
|
|
53
|
-
run: NODE_ENV=production npm ci
|
|
54
|
-
- name: Setup AWS Instance
|
|
55
|
-
id: aws-setup
|
|
56
|
-
run: |
|
|
57
|
-
OUTPUT=$(./setup/aws/spawn-runner.sh | tee /dev/stderr) # Capture and display output
|
|
58
|
-
echo "$OUTPUT"
|
|
59
|
-
PUBLIC_IP=$(echo "$OUTPUT" | grep "PUBLIC_IP=" | cut -d'=' -f2)
|
|
60
|
-
INSTANCE_ID=$(echo "$OUTPUT" | grep "INSTANCE_ID=" | cut -d'=' -f2)
|
|
61
|
-
AWS_REGION=$(echo "$OUTPUT" | grep "AWS_REGION=" | cut -d'=' -f2)
|
|
62
|
-
echo "public-ip=$PUBLIC_IP" >> $GITHUB_OUTPUT
|
|
63
|
-
echo "instance-id=$INSTANCE_ID" >> $GITHUB_OUTPUT
|
|
64
|
-
echo "aws-region=$AWS_REGION" >> $GITHUB_OUTPUT
|
|
65
|
-
env:
|
|
66
|
-
FORCE_COLOR: 3
|
|
67
|
-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
68
|
-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
69
|
-
AWS_REGION: us-east-2
|
|
70
|
-
AWS_LAUNCH_TEMPLATE_ID: lt-00d02f31cfc602f27
|
|
71
|
-
AMI_ID: ami-085f872ca0cd80fed
|
|
72
|
-
RESOLUTION_WIDTH: 1920
|
|
73
|
-
RESOLUTION_HEIGHT: 1080
|
|
74
|
-
- name: Run TestDriver
|
|
75
|
-
run: node bin/testdriverai.js run testdriver/acceptance/${{ matrix.test }} --ip="${{ steps.aws-setup.outputs.public-ip }}" --junit=out.xml
|
|
76
|
-
env:
|
|
77
|
-
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
78
|
-
TD_WEBSITE: https://testdriver-sandbox.vercel.app
|
|
79
|
-
TD_THIS_FILE: ${{ matrix.test }}
|
|
80
|
-
- name: Upload TestDriver AI CLI logs
|
|
81
|
-
if: always()
|
|
82
|
-
uses: actions/upload-artifact@v4
|
|
83
|
-
with:
|
|
84
|
-
name: testdriverai-cli-logs-${{ matrix.test }}
|
|
85
|
-
path: /tmp/testdriverai-cli-*.log
|
|
86
|
-
if-no-files-found: warn
|
|
87
|
-
retention-days: 30
|
|
88
|
-
- name: Upload test results as artifact
|
|
89
|
-
if: always()
|
|
90
|
-
uses: actions/upload-artifact@v4
|
|
91
|
-
with:
|
|
92
|
-
name: test-results-${{ matrix.test }}
|
|
93
|
-
path: out.xml
|
|
94
|
-
retention-days: 30
|
|
95
|
-
- name: Shutdown AWS Instance
|
|
96
|
-
if: always()
|
|
97
|
-
run: aws ec2 terminate-instances --region "$AWS_REGION" --instance-ids "$INSTANCE_ID"
|
|
98
|
-
env:
|
|
99
|
-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
100
|
-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
101
|
-
AWS_REGION: ${{ steps.aws-setup.outputs.aws-region }}
|
|
102
|
-
INSTANCE_ID: ${{ steps.aws-setup.outputs.instance-id }}
|
package/docs/apps/tauri-apps.mdx
DELETED
|
@@ -1,361 +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
|
-
> \
|
|
11
|
-
> – [https://tauri.app/start](https://tauri.app/start/)
|
|
12
|
-
|
|
13
|
-
## Testing Tauri apps with TestDriver
|
|
14
|
-
|
|
15
|
-
In this guide, we'll leverage [Playwright](https://playwright.dev/) and the [TestDriver Playwright SDK](/getting-started/playwright) to convert the [Tauri Quick Start](https://tauri.app/start/create-project/) to TestDriver's selectorless, Vision AI.
|
|
16
|
-
|
|
17
|
-
<Info>View Source: https://github.com/testdriverai/demo-tauri-app</Info>
|
|
18
|
-
|
|
19
|
-
### Requirements
|
|
20
|
-
|
|
21
|
-
To start testing your Tauri app with TestDriver, you need the following:
|
|
22
|
-
|
|
23
|
-
<AccordionGroup>
|
|
24
|
-
<Accordion title="Create a TestDriver account">
|
|
25
|
-
<Steps>
|
|
26
|
-
<Step title="Create a TestDriver Account">
|
|
27
|
-
You will need a [Free TestDriver Account](https://app.testdriver.ai/team) to get an API key.
|
|
28
|
-
|
|
29
|
-
<Card title="Sign Up for TestDriver" icon="user-plus" horizontal href="https://app.testdriver.ai/team">
|
|
30
|
-
|
|
31
|
-
</Card>
|
|
32
|
-
</Step>
|
|
33
|
-
<Step title="Set up your environment">
|
|
34
|
-
Copy your API key from [your TestDriver dashboard](https://app.testdriver.ai/team), and set it as an environment variable.
|
|
35
|
-
|
|
36
|
-
<Tabs>
|
|
37
|
-
<Tab title="macOS / Linux">
|
|
38
|
-
Export an environment variable on macOS or Linux systems:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
export TD_API_KEY="your_api_key_here"
|
|
42
|
-
```
|
|
43
|
-
</Tab>
|
|
44
|
-
<Tab title="Windows">
|
|
45
|
-
Export an environment variable in PowerShell:
|
|
46
|
-
|
|
47
|
-
```powershell
|
|
48
|
-
setx TD_API_KEY "your_api_key_here"
|
|
49
|
-
```
|
|
50
|
-
</Tab>
|
|
51
|
-
</Tabs>
|
|
52
|
-
</Step>
|
|
53
|
-
</Steps>
|
|
54
|
-
|
|
55
|
-
</Accordion>
|
|
56
|
-
<Accordion title="Create a Tauri project">
|
|
57
|
-
<Note>
|
|
58
|
-
Follow Tauri's [Create a Project](https://tauri.app/start/create-project/)
|
|
59
|
-
guide.
|
|
60
|
-
</Note>
|
|
61
|
-
</Accordion>
|
|
62
|
-
<Accordion title="Create a Playwright project">
|
|
63
|
-
<Info>
|
|
64
|
-
This is a condensed version of [Playwright's Installation Instructions](https://playwright.dev/docs/intro).
|
|
65
|
-
|
|
66
|
-
**If you're new to Playwright, you should follow their guide first.**
|
|
67
|
-
</Info>
|
|
68
|
-
In your Tauri project, run:
|
|
69
|
-
|
|
70
|
-
<Tabs>
|
|
71
|
-
<Tab title="npm">
|
|
72
|
-
```bash
|
|
73
|
-
npm init playwright@latest
|
|
74
|
-
```
|
|
75
|
-
</Tab>
|
|
76
|
-
<Tab title="yarn">
|
|
77
|
-
```bash
|
|
78
|
-
yarn create playwright
|
|
79
|
-
```
|
|
80
|
-
</Tab>
|
|
81
|
-
<Tab title="pnpm">
|
|
82
|
-
```bash
|
|
83
|
-
pnpm create playwright
|
|
84
|
-
```
|
|
85
|
-
</Tab>
|
|
86
|
-
</Tabs>
|
|
87
|
-
Select the following options when prompted:
|
|
88
|
-
|
|
89
|
-
```console
|
|
90
|
-
✔ Do you want to use TypeScript or JavaScript?
|
|
91
|
-
> TypeScript
|
|
92
|
-
✔ Where to put your end-to-end tests?
|
|
93
|
-
> tests
|
|
94
|
-
✔ Add a GitHub Actions workflow? (y/N)
|
|
95
|
-
> N
|
|
96
|
-
✔ Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n)
|
|
97
|
-
> Y
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
</Accordion>
|
|
101
|
-
<Accordion title="Install the TestDriver Playwright SDK">
|
|
102
|
-
`@testdriver.ai/playwright` is an AI-powered extension of `@playwright/test`.
|
|
103
|
-
|
|
104
|
-
<Tabs>
|
|
105
|
-
<Tab title="npm">
|
|
106
|
-
```bash
|
|
107
|
-
npm install @testdriver.ai/playwright
|
|
108
|
-
```
|
|
109
|
-
</Tab>
|
|
110
|
-
<Tab title="yarn">
|
|
111
|
-
```bash
|
|
112
|
-
yarn add @testdriver.ai/playwright
|
|
113
|
-
```
|
|
114
|
-
</Tab>
|
|
115
|
-
<Tab title="pnpm">
|
|
116
|
-
```bash
|
|
117
|
-
pnpm add @testdriver.ai/playwright
|
|
118
|
-
```
|
|
119
|
-
</Tab>
|
|
120
|
-
</Tabs>
|
|
121
|
-
|
|
122
|
-
</Accordion>
|
|
123
|
-
</AccordionGroup>
|
|
124
|
-
|
|
125
|
-
## Testing the Tauri Web App
|
|
126
|
-
|
|
127
|
-
### Setup
|
|
128
|
-
|
|
129
|
-
First, we need to modify the default Playwright configuration and our Tauri project to work together:
|
|
130
|
-
|
|
131
|
-
<Steps>
|
|
132
|
-
<Step title="Configure Playwright to start the Tauri frontend">
|
|
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
|
-
<Step title="Mock Tauri APIs">
|
|
152
|
-
Since we're testing the Tauri frontend, we need to [mock IPC Requests](https://tauri.app/develop/tests/mocking/)
|
|
153
|
-
to simulate `invoke` calls to the Rust backend:
|
|
154
|
-
|
|
155
|
-
```html src/index.html
|
|
156
|
-
<body>
|
|
157
|
-
<div id="root"></div>
|
|
158
|
-
<!-- [!code ++:7] -->
|
|
159
|
-
<script type="module">
|
|
160
|
-
// This is set in playwright.config.ts to allow our tests to mock Tauri IPC `invoke` calls
|
|
161
|
-
if (import.meta.env.VITE_PLAYWRIGHT) {
|
|
162
|
-
const { mockIPC } = await import("@tauri-apps/api/mocks");
|
|
163
|
-
window.mockIPC = mockIPC;
|
|
164
|
-
}
|
|
165
|
-
</script>
|
|
166
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
167
|
-
</body>
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
We only need to do this once, as we'll be accessing `window.mockIPC` in our tests.
|
|
171
|
-
|
|
172
|
-
</Step>
|
|
173
|
-
<Step title="Create a new test file">
|
|
174
|
-
Create a new file (e.g. `tests/testdriver.spec.ts`) with:
|
|
175
|
-
|
|
176
|
-
```typescript tests/testdriver.spec.ts
|
|
177
|
-
import type { mockIPC } from "@tauri-apps/api/mocks";
|
|
178
|
-
import { expect, test } from "@playwright/test";
|
|
179
|
-
|
|
180
|
-
test.beforeEach(async ({ page }) => {
|
|
181
|
-
await page.goto("http://localhost:1420");
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test("should have title", async ({ page }) => {
|
|
185
|
-
await expect(page).toHaveTitle("Tauri + React + TypeScript");
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
</Step>
|
|
190
|
-
<Step title="Run Playwright in UI Mode">
|
|
191
|
-
Now we're ready to run Playwright and start working on our tests:
|
|
192
|
-
|
|
193
|
-
<Tabs>
|
|
194
|
-
<Tab title="npm">
|
|
195
|
-
```bash
|
|
196
|
-
npx playwright test --ui
|
|
197
|
-
```
|
|
198
|
-
</Tab>
|
|
199
|
-
<Tab title="yarn">
|
|
200
|
-
```bash
|
|
201
|
-
yarn playwright test --ui
|
|
202
|
-
```
|
|
203
|
-
</Tab>
|
|
204
|
-
<Tab title="pnpm">
|
|
205
|
-
```bash
|
|
206
|
-
pnpm exec playwright test --ui
|
|
207
|
-
```
|
|
208
|
-
</Tab>
|
|
209
|
-
</Tabs>
|
|
210
|
-

|
|
211
|
-
|
|
212
|
-
Click the <Icon icon="play" /> button to successfully run the tests in the UI.
|
|
213
|
-
|
|
214
|
-
<Tip>
|
|
215
|
-
Click the <Icon icon="eye" /> button to automatically re-run tests on save.
|
|
216
|
-
</Tip>
|
|
217
|
-
|
|
218
|
-
</Step>
|
|
219
|
-
</Steps>
|
|
220
|
-
|
|
221
|
-
### Usage
|
|
222
|
-
|
|
223
|
-
#### Import the TestDriver Playwright SDK
|
|
224
|
-
|
|
225
|
-
By changing **1 line**, we can add TestDriver's AI capabilities to Playwright:
|
|
226
|
-
|
|
227
|
-
```typescript tests/testdriver.spec.ts
|
|
228
|
-
import type { mockIPC } from "@tauri-apps/api/mocks";
|
|
229
|
-
// [!code --]
|
|
230
|
-
import { expect, test } from "@playwright/test";
|
|
231
|
-
// [!code ++]
|
|
232
|
-
import { expect, test } from "@testdriver.ai/playwright";
|
|
233
|
-
|
|
234
|
-
// For type-safety of the mockIPC function
|
|
235
|
-
declare global {
|
|
236
|
-
interface Window {
|
|
237
|
-
mockIPC: typeof mockIPC;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
test.beforeEach(async ({ page }) => {
|
|
242
|
-
await page.goto("http://localhost:1420");
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
test("should have title", async ({ page }) => {
|
|
246
|
-
await expect(page).toHaveTitle("Tauri + React + TypeScript");
|
|
247
|
-
});
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Notice how we're able to continue using Playwright's API (`toHaveTitle`)
|
|
251
|
-
with `@testdriver.ai/playwright`.
|
|
252
|
-
|
|
253
|
-
The test continues to pass as before, so now we can update our test to use natural language instead of selectors.
|
|
254
|
-
|
|
255
|
-
#### Assertions with `expect.toMatchPrompt`
|
|
256
|
-
|
|
257
|
-
With Playwright, we would normally use a `getByRole` selector to assert the heading text:
|
|
258
|
-
|
|
259
|
-
```typescript tests/example.spec.ts
|
|
260
|
-
test("should have heading", async ({ page }) => {
|
|
261
|
-
await expect(
|
|
262
|
-
page.getByRole("heading", { name: "Installation" }),
|
|
263
|
-
).toBeVisible();
|
|
264
|
-
});
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
With TestDriver, we can use natural language with `toMatchPrompt` instead:
|
|
268
|
-
|
|
269
|
-
```typescript tests/testdriver.spec.ts
|
|
270
|
-
test("should have heading", async ({ page }) => {
|
|
271
|
-
// [!code --:3]
|
|
272
|
-
await expect(
|
|
273
|
-
page.getByRole("heading", { name: "Installation" }),
|
|
274
|
-
).toBeVisible();
|
|
275
|
-
// [!code ++:1]
|
|
276
|
-
await expect(page).toMatchPrompt("Heading says 'Welcome to Tauri + React'");
|
|
277
|
-
});
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
#### Agentic tests with `test.agent`
|
|
281
|
-
|
|
282
|
-
With TestDriver, we can skip the test implementation **entirely** and let AI perform the test for us:
|
|
283
|
-
|
|
284
|
-
<Steps>
|
|
285
|
-
<Step title="Mock the `greet` call">
|
|
286
|
-
First, we need to [`mock our invoke calls`](https://tauri.app/develop/tests/mocking/#ipc-requests),
|
|
287
|
-
since we're testing the frontend behavior and not our Tauri backend:
|
|
288
|
-
|
|
289
|
-
```typescript tests/testdriver.spec.ts
|
|
290
|
-
test.beforeEach(async ({ page }) => {
|
|
291
|
-
await page.goto("http://localhost:1420");
|
|
292
|
-
// [!code ++:12]
|
|
293
|
-
await page.evaluate(() => {
|
|
294
|
-
// https://tauri.app/develop/tests/mocking/#mocking-commands-for-invoke
|
|
295
|
-
window.mockIPC((cmd, args) => {
|
|
296
|
-
switch (cmd) {
|
|
297
|
-
case "greet":
|
|
298
|
-
args = args as { name: string };
|
|
299
|
-
return `Hello, ${args.name}! You've been greeted from Rust!`;
|
|
300
|
-
default:
|
|
301
|
-
throw new Error(`Unsupported command: ${cmd}`);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
</Step>
|
|
309
|
-
<Step title="Add an Agentic Test">
|
|
310
|
-
Next, wrap a _prompt_ in `test.agent` to perform the test:
|
|
311
|
-
|
|
312
|
-
```typescript tests/testdriver.spec.ts
|
|
313
|
-
test.describe("should greet with name", () => {
|
|
314
|
-
test.agent(`
|
|
315
|
-
- Enter the name "Tauri"
|
|
316
|
-
- Click the "Greet" button
|
|
317
|
-
- You should see the text "Hello, Tauri! You've been greeted from Rust!"
|
|
318
|
-
`);
|
|
319
|
-
});
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
</Step>
|
|
323
|
-
</Steps>
|
|
324
|
-
|
|
325
|
-
#### Continued Reading
|
|
326
|
-
|
|
327
|
-
[Learn more about TestDriver's Playwright SDK](/getting-started/playwright)
|
|
328
|
-
|
|
329
|
-
## Testing the Tauri Desktop App
|
|
330
|
-
|
|
331
|
-
We can use TestDriver and natural language to test our Tauri desktop app:
|
|
332
|
-
|
|
333
|
-
<Steps>
|
|
334
|
-
<Step title="Run the Desktop App">
|
|
335
|
-
<Tabs>
|
|
336
|
-
<Tab title="npm">```bash npm run tauri dev ```</Tab>
|
|
337
|
-
<Tab title="yarn">```bash yarn tauri dev ```</Tab>
|
|
338
|
-
<Tab title="pnpm">```bash pnpm tauri dev ```</Tab>
|
|
339
|
-
</Tabs>
|
|
340
|
-
</Step>
|
|
341
|
-
<Step title="Continued Reading">
|
|
342
|
-
<Note>See [Desktop Apps](/apps/desktop-apps) for more information.</Note>
|
|
343
|
-
</Step>
|
|
344
|
-
</Steps>
|
|
345
|
-
|
|
346
|
-
## Testing the Tauri Mobile App
|
|
347
|
-
|
|
348
|
-
We can use TestDriver and natural language to test our Tauri iOS app:
|
|
349
|
-
|
|
350
|
-
<Steps>
|
|
351
|
-
<Step title="Run the Mobile App">
|
|
352
|
-
<Tabs>
|
|
353
|
-
<Tab title="npm">```bash npm run tauri ios dev ```</Tab>
|
|
354
|
-
<Tab title="yarn">```bash yarn tauri ios dev ```</Tab>
|
|
355
|
-
<Tab title="pnpm">```bash pnpm tauri ios dev ```</Tab>
|
|
356
|
-
</Tabs>
|
|
357
|
-
</Step>
|
|
358
|
-
<Step title="Continued Reading">
|
|
359
|
-
<Note>See [Mobile Apps](/apps/mobile-apps) for more information.</Note>
|
|
360
|
-
</Step>
|
|
361
|
-
</Steps>
|