testdriverai 7.3.12 → 7.3.13
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/skills/testdriver:ai/SKILL.md +204 -0
- package/.github/skills/testdriver:assert/SKILL.md +284 -0
- package/.github/skills/testdriver:aws-setup/SKILL.md +515 -0
- package/.github/skills/testdriver:caching/SKILL.md +124 -0
- package/.github/skills/testdriver:captcha/SKILL.md +159 -0
- package/.github/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/.github/skills/testdriver:click/SKILL.md +286 -0
- package/.github/skills/testdriver:client/SKILL.md +339 -0
- package/.github/skills/testdriver:cloud/SKILL.md +119 -0
- package/.github/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/.github/skills/testdriver:dashcam/SKILL.md +418 -0
- package/.github/skills/testdriver:debugging-with-screenshots/SKILL.md +271 -0
- package/.github/skills/testdriver:device-config/SKILL.md +317 -0
- package/.github/skills/testdriver:double-click/SKILL.md +102 -0
- package/.github/skills/testdriver:elements/SKILL.md +605 -0
- package/.github/skills/testdriver:enterprise/SKILL.md +114 -0
- package/.github/skills/testdriver:examples/SKILL.md +7 -0
- package/.github/skills/testdriver:exec/SKILL.md +345 -0
- package/.github/skills/testdriver:find/SKILL.md +721 -0
- package/.github/skills/testdriver:focus-application/SKILL.md +293 -0
- package/.github/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/.github/skills/testdriver:hover/SKILL.md +278 -0
- package/.github/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/.github/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/.github/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/.github/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/.github/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/.github/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/.github/skills/testdriver:press-keys/SKILL.md +348 -0
- package/.github/skills/testdriver:quickstart/SKILL.md +161 -0
- package/.github/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/.github/skills/testdriver:right-click/SKILL.md +123 -0
- package/.github/skills/testdriver:running-tests/SKILL.md +181 -0
- package/.github/skills/testdriver:screenshot/SKILL.md +167 -0
- package/.github/skills/testdriver:scroll/SKILL.md +299 -0
- package/.github/skills/testdriver:secrets/SKILL.md +115 -0
- package/.github/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/.github/skills/testdriver:test-writer/SKILL.md +451 -0
- package/.github/skills/testdriver:testdriver/SKILL.md +523 -0
- package/.github/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/.github/skills/testdriver:type/SKILL.md +357 -0
- package/.github/skills/testdriver:variables/SKILL.md +111 -0
- package/.github/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/.github/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/.github/workflows/acceptance-windows-scheduled.yaml +6 -1
- package/.github/workflows/acceptance.yaml +0 -36
- package/.github/workflows/update-examples.yaml +53 -0
- package/CHANGELOG.md +4 -0
- package/agent/events.js +1 -0
- package/agent/index.js +8 -0
- package/agent/lib/commands.js +48 -29
- package/agent/lib/redraw.js +3 -1
- package/agent/lib/sandbox.js +166 -14
- package/agent/lib/sdk.js +142 -3
- package/agent/lib/system.js +4 -6
- package/ai/skills/testdriver:ai/SKILL.md +204 -0
- package/ai/skills/testdriver:assert/SKILL.md +315 -0
- package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
- package/ai/skills/testdriver:caching/SKILL.md +124 -0
- package/ai/skills/testdriver:captcha/SKILL.md +159 -0
- package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/ai/skills/testdriver:click/SKILL.md +286 -0
- package/ai/skills/testdriver:client/SKILL.md +372 -0
- package/ai/skills/testdriver:cloud/SKILL.md +119 -0
- package/ai/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/ai/skills/testdriver:dashcam/SKILL.md +418 -0
- package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +401 -0
- package/ai/skills/testdriver:device-config/SKILL.md +317 -0
- package/ai/skills/testdriver:double-click/SKILL.md +102 -0
- package/ai/skills/testdriver:elements/SKILL.md +605 -0
- package/ai/skills/testdriver:enterprise/SKILL.md +114 -0
- package/ai/skills/testdriver:examples/SKILL.md +7 -0
- package/ai/skills/testdriver:exec/SKILL.md +345 -0
- package/ai/skills/testdriver:find/SKILL.md +745 -0
- package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
- package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/ai/skills/testdriver:hover/SKILL.md +278 -0
- package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/ai/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/ai/skills/testdriver:ocr/SKILL.md +235 -0
- package/ai/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
- package/ai/skills/testdriver:quickstart/SKILL.md +146 -0
- package/ai/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/ai/skills/testdriver:right-click/SKILL.md +123 -0
- package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
- package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
- package/ai/skills/testdriver:scroll/SKILL.md +335 -0
- package/ai/skills/testdriver:secrets/SKILL.md +115 -0
- package/ai/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/ai/skills/testdriver:test-writer/SKILL.md +451 -0
- package/ai/skills/testdriver:testdriver/SKILL.md +631 -0
- package/ai/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/ai/skills/testdriver:type/SKILL.md +357 -0
- package/ai/skills/testdriver:variables/SKILL.md +111 -0
- package/ai/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/debugger/index.html +12 -2
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/find.mdx +1 -0
- package/examples/config.mjs +1 -1
- package/examples/findall-coffee-icons.test.mjs +42 -0
- package/examples/flake-diffthreshold-001.test.mjs +9 -0
- package/examples/flake-diffthreshold-01.test.mjs +9 -0
- package/examples/flake-diffthreshold-05.test.mjs +9 -0
- package/examples/{z_flake-noredraw-cache.test.mjs → flake-noredraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-noredraw-nocache.test.mjs → flake-noredraw-nocache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-cache.test.mjs → flake-redraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-nocache.test.mjs → flake-redraw-nocache.test.mjs} +2 -2
- package/examples/flake-rocket-match.test.mjs +30 -0
- package/examples/{z_flake-shared.mjs → flake-shared.mjs} +2 -2
- package/examples/parse.test.mjs +19 -0
- package/examples/scroll-keyboard.test.mjs +1 -1
- package/interfaces/cli/lib/base.js +6 -0
- package/interfaces/logger.js +51 -13
- package/interfaces/vitest-plugin.mjs +137 -0
- package/lib/core/index.d.ts +22 -0
- package/lib/init-project.js +105 -6
- package/lib/vitest/hooks.mjs +2 -5
- package/lib/vitest/setup-disable-defender.mjs +52 -0
- package/package.json +2 -1
- package/sdk-log-formatter.js +90 -0
- package/sdk.d.ts +88 -51
- package/sdk.js +126 -18
- package/setup/aws/disable-defender.sh +42 -0
- package/vitest.config.mjs +1 -3
- package/examples/z_flake-diffthreshold-001.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-01.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-05.test.mjs +0 -9
- /package/{examples → manual}/captcha-api.test.mjs +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:reusable-code
|
|
3
|
+
description: Build maintainable test suites with reusable code patterns
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from reusable-code.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
As your test suite grows, you'll want to extract common patterns into reusable code. This keeps tests DRY, readable, and easy to maintain.
|
|
8
|
+
|
|
9
|
+
## Helper Functions
|
|
10
|
+
|
|
11
|
+
The simplest approach is extracting common actions into helper functions. Create a `helpers/` directory for shared utilities:
|
|
12
|
+
|
|
13
|
+
```javascript test/helpers/auth.js
|
|
14
|
+
export async function login(testdriver, { email, password }) {
|
|
15
|
+
const emailInput = await testdriver.find('email input');
|
|
16
|
+
await emailInput.click();
|
|
17
|
+
await testdriver.type(email);
|
|
18
|
+
|
|
19
|
+
const passwordInput = await testdriver.find('password input');
|
|
20
|
+
await passwordInput.click();
|
|
21
|
+
await testdriver.type(password);
|
|
22
|
+
|
|
23
|
+
const loginButton = await testdriver.find('login button');
|
|
24
|
+
await loginButton.click();
|
|
25
|
+
|
|
26
|
+
const result = await testdriver.assert('user is logged in');
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function logout(testdriver) {
|
|
31
|
+
const userMenu = await testdriver.find('user menu');
|
|
32
|
+
await userMenu.click();
|
|
33
|
+
|
|
34
|
+
const logoutButton = await testdriver.find('logout button');
|
|
35
|
+
await logoutButton.click();
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Now import and use these helpers in any test:
|
|
40
|
+
|
|
41
|
+
```javascript test/checkout.test.mjs
|
|
42
|
+
import { describe, expect, it } from "vitest";
|
|
43
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
44
|
+
import { login } from './helpers/auth.js';
|
|
45
|
+
|
|
46
|
+
describe("Checkout", () => {
|
|
47
|
+
it("should complete checkout as logged in user", async (context) => {
|
|
48
|
+
const testdriver = TestDriver(context);
|
|
49
|
+
|
|
50
|
+
await testdriver.provision.chrome({
|
|
51
|
+
url: 'https://shop.example.com',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Use the helper
|
|
55
|
+
await login(testdriver, {
|
|
56
|
+
email: 'user@example.com',
|
|
57
|
+
password: 'password123'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Continue with checkout steps...
|
|
61
|
+
const cartButton = await testdriver.find('cart button');
|
|
62
|
+
await cartButton.click();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Page Objects
|
|
68
|
+
|
|
69
|
+
For larger test suites, the Page Object pattern encapsulates all interactions with a specific page or component:
|
|
70
|
+
|
|
71
|
+
```javascript test/pages/LoginPage.js
|
|
72
|
+
export class LoginPage {
|
|
73
|
+
constructor(testdriver) {
|
|
74
|
+
this.td = testdriver;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async enterEmail(email) {
|
|
78
|
+
const input = await this.td.find('email input');
|
|
79
|
+
await input.click();
|
|
80
|
+
await this.td.type(email);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async enterPassword(password) {
|
|
84
|
+
const input = await this.td.find('password input');
|
|
85
|
+
await input.click();
|
|
86
|
+
await this.td.type(password);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async submit() {
|
|
90
|
+
const button = await this.td.find('submit button');
|
|
91
|
+
await button.click();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async login(email, password) {
|
|
95
|
+
await this.enterEmail(email);
|
|
96
|
+
await this.enterPassword(password);
|
|
97
|
+
await this.submit();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async assertError(message) {
|
|
101
|
+
return await this.td.assert(`error message shows "${message}"`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async assertLoggedIn() {
|
|
105
|
+
return await this.td.assert('user dashboard is visible');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use the page object in your tests:
|
|
111
|
+
|
|
112
|
+
```javascript test/auth.test.mjs
|
|
113
|
+
import { describe, expect, it } from "vitest";
|
|
114
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
115
|
+
import { LoginPage } from './pages/LoginPage.js';
|
|
116
|
+
|
|
117
|
+
describe("Authentication", () => {
|
|
118
|
+
it("should show error for invalid credentials", async (context) => {
|
|
119
|
+
const testdriver = TestDriver(context);
|
|
120
|
+
|
|
121
|
+
await testdriver.provision.chrome({
|
|
122
|
+
url: 'https://app.example.com/login',
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const loginPage = new LoginPage(testdriver);
|
|
126
|
+
|
|
127
|
+
await loginPage.login('invalid@test.com', 'wrongpassword');
|
|
128
|
+
|
|
129
|
+
const hasError = await loginPage.assertError('Invalid credentials');
|
|
130
|
+
expect(hasError).toBeTruthy();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should redirect to dashboard on success", async (context) => {
|
|
134
|
+
const testdriver = TestDriver(context);
|
|
135
|
+
|
|
136
|
+
await testdriver.provision.chrome({
|
|
137
|
+
url: 'https://app.example.com/login',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const loginPage = new LoginPage(testdriver);
|
|
141
|
+
|
|
142
|
+
await loginPage.login('valid@test.com', 'correctpassword');
|
|
143
|
+
|
|
144
|
+
const isLoggedIn = await loginPage.assertLoggedIn();
|
|
145
|
+
expect(isLoggedIn).toBeTruthy();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Shared Test Fixtures
|
|
151
|
+
|
|
152
|
+
Create reusable fixtures for common test setup scenarios:
|
|
153
|
+
|
|
154
|
+
```javascript test/fixtures/index.js
|
|
155
|
+
export const testUsers = {
|
|
156
|
+
admin: { email: 'admin@example.com', password: 'admin123' },
|
|
157
|
+
regular: { email: 'user@example.com', password: 'user123' },
|
|
158
|
+
guest: { email: 'guest@example.com', password: 'guest123' },
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const testUrls = {
|
|
162
|
+
staging: 'https://staging.example.com',
|
|
163
|
+
production: 'https://example.com',
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export async function setupAuthenticatedSession(testdriver, user = testUsers.regular) {
|
|
167
|
+
const emailInput = await testdriver.find('email input');
|
|
168
|
+
await emailInput.click();
|
|
169
|
+
await testdriver.type(user.email);
|
|
170
|
+
|
|
171
|
+
const passwordInput = await testdriver.find('password input');
|
|
172
|
+
await passwordInput.click();
|
|
173
|
+
await testdriver.type(user.password);
|
|
174
|
+
|
|
175
|
+
const loginButton = await testdriver.find('login button');
|
|
176
|
+
await loginButton.click();
|
|
177
|
+
|
|
178
|
+
await testdriver.assert('user is logged in');
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```javascript test/admin.test.mjs
|
|
183
|
+
import { describe, expect, it } from "vitest";
|
|
184
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
185
|
+
import { testUsers, testUrls, setupAuthenticatedSession } from './fixtures/index.js';
|
|
186
|
+
|
|
187
|
+
describe("Admin Panel", () => {
|
|
188
|
+
it("should access admin settings", async (context) => {
|
|
189
|
+
const testdriver = TestDriver(context);
|
|
190
|
+
|
|
191
|
+
await testdriver.provision.chrome({
|
|
192
|
+
url: `${testUrls.staging}/login`,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await setupAuthenticatedSession(testdriver, testUsers.admin);
|
|
196
|
+
|
|
197
|
+
const settingsLink = await testdriver.find('admin settings link');
|
|
198
|
+
await settingsLink.click();
|
|
199
|
+
|
|
200
|
+
const result = await testdriver.assert('admin settings panel is visible');
|
|
201
|
+
expect(result).toBeTruthy();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Suggested Project Structure
|
|
207
|
+
|
|
208
|
+
<FileTree>
|
|
209
|
+
<Folder name="test" defaultOpen>
|
|
210
|
+
<Folder name="fixtures" defaultOpen>
|
|
211
|
+
<File name="index.js" />
|
|
212
|
+
</Folder>
|
|
213
|
+
<Folder name="helpers" defaultOpen>
|
|
214
|
+
<File name="auth.js" />
|
|
215
|
+
<File name="navigation.js" />
|
|
216
|
+
<File name="forms.js" />
|
|
217
|
+
</Folder>
|
|
218
|
+
<Folder name="pages" defaultOpen>
|
|
219
|
+
<File name="LoginPage.js" />
|
|
220
|
+
<File name="DashboardPage.js" />
|
|
221
|
+
<File name="CheckoutPage.js" />
|
|
222
|
+
</Folder>
|
|
223
|
+
<Folder name="specs" defaultOpen>
|
|
224
|
+
<File name="auth.test.mjs" />
|
|
225
|
+
<File name="checkout.test.mjs" />
|
|
226
|
+
<File name="search.test.mjs" />
|
|
227
|
+
</Folder>
|
|
228
|
+
</Folder>
|
|
229
|
+
</FileTree>
|
|
230
|
+
|
|
231
|
+
| Folder | Purpose |
|
|
232
|
+
|--------|---------|
|
|
233
|
+
| `fixtures/` | Test data and setup utilities |
|
|
234
|
+
| `helpers/` | Reusable helper functions |
|
|
235
|
+
| `pages/` | Page object classes |
|
|
236
|
+
| `specs/` | Test files |
|
|
237
|
+
|
|
238
|
+
<Tip>
|
|
239
|
+
Start simple with helper functions. Only introduce page objects when you find yourself duplicating the same element interactions across multiple tests.
|
|
240
|
+
</Tip>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:right-click
|
|
3
|
+
description: Perform a right-click action to open context menus
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from right-click.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `rightClick()` method performs a right-click action on an element, typically used to open context menus. You can either call it on an [`Element`](/v7/core-concepts/elements) instance or use it directly with a selector.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// Right-click on an element
|
|
15
|
+
await element.rightClick();
|
|
16
|
+
|
|
17
|
+
// Right-click using a selector
|
|
18
|
+
await ai.rightClick('selector');
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
When called on an `Element`, no parameters are required.
|
|
24
|
+
|
|
25
|
+
When called directly on the AI client:
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `selector` | `string` | The selector describing the element to right-click |
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
Returns a `Promise<void>` that resolves when the right-click action completes.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Right-Click to Open Context Menu
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const fileItem = await ai.find('README.md file');
|
|
41
|
+
await fileItem.rightClick();
|
|
42
|
+
|
|
43
|
+
// Select menu option
|
|
44
|
+
await ai.click('Delete from context menu');
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Direct Right-Click with Selector
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
await ai.rightClick('image in the gallery');
|
|
51
|
+
await ai.click('Save image as');
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### VS Code Context Menu
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { test } from 'vitest';
|
|
58
|
+
import { vscode } from '@testdriver/sdk';
|
|
59
|
+
|
|
60
|
+
test('renames a file via context menu', async () => {
|
|
61
|
+
const { ai } = await vscode();
|
|
62
|
+
|
|
63
|
+
// Right-click on a file
|
|
64
|
+
await ai.rightClick('test.js in the file explorer');
|
|
65
|
+
|
|
66
|
+
// Click rename option
|
|
67
|
+
await ai.click('Rename');
|
|
68
|
+
|
|
69
|
+
// Type new name
|
|
70
|
+
await ai.type('test.spec.js');
|
|
71
|
+
await ai.pressKeys('Enter');
|
|
72
|
+
|
|
73
|
+
// Verify rename
|
|
74
|
+
const renamedFile = await ai.find('test.spec.js in the file explorer');
|
|
75
|
+
expect(renamedFile).toBeTruthy();
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Browser Context Menu
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { test } from 'vitest';
|
|
83
|
+
import { chrome } from '@testdriver/sdk';
|
|
84
|
+
|
|
85
|
+
test('opens link in new tab', async () => {
|
|
86
|
+
const { ai } = await chrome('https://example.com');
|
|
87
|
+
|
|
88
|
+
// Right-click on a link
|
|
89
|
+
await ai.rightClick('Documentation link');
|
|
90
|
+
|
|
91
|
+
// Select "Open in new tab"
|
|
92
|
+
await ai.click('Open link in new tab');
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Custom Context Menu in Web App
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
test('uses custom context menu', async () => {
|
|
100
|
+
const { ai } = await chrome('https://app.example.com');
|
|
101
|
+
|
|
102
|
+
// Right-click on custom element
|
|
103
|
+
await ai.rightClick('project item in the list');
|
|
104
|
+
|
|
105
|
+
// Wait for custom menu to appear
|
|
106
|
+
await ai.find('custom context menu');
|
|
107
|
+
|
|
108
|
+
// Click menu option
|
|
109
|
+
await ai.click('Duplicate project');
|
|
110
|
+
|
|
111
|
+
// Verify duplication
|
|
112
|
+
const duplicatedProject = await ai.find('project item (copy)');
|
|
113
|
+
expect(duplicatedProject).toBeTruthy();
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Related Methods
|
|
118
|
+
|
|
119
|
+
- [`click()`](/v7/click) - Single click on an element
|
|
120
|
+
- [`doubleClick()`](/v7/double-click) - Double-click on an element
|
|
121
|
+
- [`mouseDown()`](/v7/mouse-down) - Press mouse button without releasing
|
|
122
|
+
- [`mouseUp()`](/v7/mouse-up) - Release mouse button
|
|
123
|
+
- [`hover()`](/v7/hover) - Move mouse over element without clicking
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:running-tests
|
|
3
|
+
description: Run TestDriver tests with Vitest test runner
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from running-tests.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
Learn how to run TestDriver tests efficiently with Vitest's powerful test runner.
|
|
8
|
+
|
|
9
|
+
## Running Tests
|
|
10
|
+
|
|
11
|
+
TestDriver works with Vitest's powerful test runner.
|
|
12
|
+
|
|
13
|
+
<Info>
|
|
14
|
+
Install Vitest globally for best results: `npm install vitest -g`
|
|
15
|
+
</Info>
|
|
16
|
+
|
|
17
|
+
### Run All Tests
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
vitest run
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Executes all test files in your project once and exits. Vitest automatically discovers files matching patterns like `*.test.js`, `*.test.mjs`, or `*.spec.js`.
|
|
24
|
+
|
|
25
|
+
### Run with Coverage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
vitest run --coverage
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Generates a code coverage report showing which lines of your source code were executed during tests. Coverage helps identify untested code paths. Results are displayed in the terminal and saved to a `coverage/` directory.
|
|
32
|
+
|
|
33
|
+
<Info>
|
|
34
|
+
Coverage requires the `@vitest/coverage-v8` package. Install it with `npm install -D @vitest/coverage-v8`.
|
|
35
|
+
</Info>
|
|
36
|
+
|
|
37
|
+
### Run Specific Tests
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
vitest run login.test.js
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Runs only the specified test file. Useful when debugging a single test or working on a specific feature.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
vitest run login.test.js checkout.test.js
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Runs multiple specific test files. List as many files as needed, separated by spaces.
|
|
50
|
+
|
|
51
|
+
### Filter Tests by Name
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
vitest run --grep "login"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `--grep` flag filters tests by their name (the string passed to `it()` or `test()`). Only tests whose names match the pattern will run. Supports regex patterns for complex matching.
|
|
58
|
+
|
|
59
|
+
### Run Tests in a Folder
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
vitest run tests/e2e/
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Runs all test files within a specific directory. Great for organizing tests by type (unit, integration, e2e) and running them separately.
|
|
66
|
+
|
|
67
|
+
## Parallel Execution
|
|
68
|
+
|
|
69
|
+
TestDriver runs each test in its own cloud sandbox, enabling true parallel execution. Run your entire test suite in minutes instead of hours.
|
|
70
|
+
|
|
71
|
+
### Control Concurrency
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
vitest run --maxConcurrency=5
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The `--maxConcurrency` flag limits how many tests run simultaneously. This should match your TestDriver license slots to avoid failures from exhausted slots.
|
|
78
|
+
|
|
79
|
+
### Thread Configuration
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
vitest run --pool=threads --minThreads=2 --maxThreads=8
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Fine-tune thread allocation for optimal performance:
|
|
86
|
+
- `--pool=threads` — Uses worker threads for test isolation
|
|
87
|
+
- `--minThreads` — Minimum number of threads to keep alive (reduces startup overhead)
|
|
88
|
+
- `--maxThreads` — Maximum threads to spawn (limits resource usage)
|
|
89
|
+
|
|
90
|
+
### License Slots
|
|
91
|
+
|
|
92
|
+
Your TestDriver plan includes a set number of **license slots** that determine how many tests can run simultaneously. Each running test occupies one slot—when the test completes and the sandbox is destroyed, the slot is immediately available for the next test.
|
|
93
|
+
|
|
94
|
+
<Info>
|
|
95
|
+
View your available slots at [console.testdriver.ai](https://console.testdriver.ai). Upgrade anytime to increase parallelization.
|
|
96
|
+
</Info>
|
|
97
|
+
|
|
98
|
+
### Configuring Concurrency
|
|
99
|
+
|
|
100
|
+
Set `maxConcurrency` in your Vitest config to match your license slot limit:
|
|
101
|
+
|
|
102
|
+
```javascript vitest.config.mjs
|
|
103
|
+
import { defineConfig } from 'vitest/config';
|
|
104
|
+
import { TestDriver } from 'testdriverai/vitest';
|
|
105
|
+
|
|
106
|
+
export default defineConfig({
|
|
107
|
+
test: {
|
|
108
|
+
testTimeout: 900000,
|
|
109
|
+
hookTimeout: 900000,
|
|
110
|
+
maxConcurrency: 5, // Match your license slot limit
|
|
111
|
+
reporters: ['default', TestDriver()],
|
|
112
|
+
setupFiles: ['testdriverai/vitest/setup'],
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
<Warning>
|
|
118
|
+
Setting `maxConcurrency` higher than your license slots will cause tests to fail when slots are exhausted. Always match this value to your plan's limit.
|
|
119
|
+
</Warning>
|
|
120
|
+
|
|
121
|
+
### Why Parallelization Matters
|
|
122
|
+
|
|
123
|
+
| Test Suite | Sequential (1 slot) | Parallel (5 slots) | Parallel (10 slots) |
|
|
124
|
+
|------------|--------------------|--------------------|---------------------|
|
|
125
|
+
| 10 tests @ 2min each | 20 min | 4 min | 2 min |
|
|
126
|
+
| 50 tests @ 2min each | 100 min | 20 min | 10 min |
|
|
127
|
+
| 100 tests @ 2min each | 200 min | 40 min | 20 min |
|
|
128
|
+
|
|
129
|
+
<Tip>
|
|
130
|
+
**Pro tip:** Upgrading your plan doesn't just increase speed—it enables faster CI/CD feedback loops, letting your team ship with confidence.
|
|
131
|
+
</Tip>
|
|
132
|
+
|
|
133
|
+
<Card
|
|
134
|
+
title="View Plans & Pricing"
|
|
135
|
+
icon="credit-card"
|
|
136
|
+
href="/v7/cloud"
|
|
137
|
+
>
|
|
138
|
+
Compare plans and find the right level of parallelization for your team.
|
|
139
|
+
</Card>
|
|
140
|
+
|
|
141
|
+
## Vitest UI
|
|
142
|
+
|
|
143
|
+
Use Vitest UI for interactive debugging:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
vitest --ui
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The `--ui` flag launches a web-based interface for managing your test suite. Unlike `vitest run`, this starts in watch mode by default.
|
|
150
|
+
|
|
151
|
+
Open http://localhost:51204 to see:
|
|
152
|
+
- **Test file tree** — Browse and navigate your test structure
|
|
153
|
+
- **Test status and duration** — See pass/fail states and timing at a glance
|
|
154
|
+
- **Console output** — View logs and errors inline with each test
|
|
155
|
+
- **Re-run individual tests** — Click to re-execute specific tests without restarting
|
|
156
|
+
- **Filter and search** — Quickly find tests by name or status
|
|
157
|
+
|
|
158
|
+
<Tip>
|
|
159
|
+
Combine with `--open` to automatically open the UI in your browser: `vitest --ui --open`
|
|
160
|
+
</Tip>
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Test Reports
|
|
164
|
+
|
|
165
|
+
After running tests, view detailed reports and video replays at [console.testdriver.ai](https://console.testdriver.ai).
|
|
166
|
+
|
|
167
|
+
Reports include:
|
|
168
|
+
- **Video replays** - Watch exactly what happened during each test
|
|
169
|
+
- **Screenshots** - See the state at each step
|
|
170
|
+
- **Timing breakdown** - Identify slow operations
|
|
171
|
+
- **Error details** - Debug failures with full context
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
$ vitest run
|
|
175
|
+
|
|
176
|
+
✓ login.test.js (2) 18.4s
|
|
177
|
+
✓ user can login 12.3s
|
|
178
|
+
✓ shows error for invalid credentials 6.1s
|
|
179
|
+
|
|
180
|
+
📹 View reports at: https://console.testdriver.ai
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
<Tip>
|
|
184
|
+
Bookmark your team's dashboard at [console.testdriver.ai](https://console.testdriver.ai) for quick access to test history and analytics.
|
|
185
|
+
</Tip>
|