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.
Files changed (133) hide show
  1. package/.github/skills/testdriver:ai/SKILL.md +204 -0
  2. package/.github/skills/testdriver:assert/SKILL.md +284 -0
  3. package/.github/skills/testdriver:aws-setup/SKILL.md +515 -0
  4. package/.github/skills/testdriver:caching/SKILL.md +124 -0
  5. package/.github/skills/testdriver:captcha/SKILL.md +159 -0
  6. package/.github/skills/testdriver:ci-cd/SKILL.md +602 -0
  7. package/.github/skills/testdriver:click/SKILL.md +286 -0
  8. package/.github/skills/testdriver:client/SKILL.md +339 -0
  9. package/.github/skills/testdriver:cloud/SKILL.md +119 -0
  10. package/.github/skills/testdriver:customizing-devices/SKILL.md +153 -0
  11. package/.github/skills/testdriver:dashcam/SKILL.md +418 -0
  12. package/.github/skills/testdriver:debugging-with-screenshots/SKILL.md +271 -0
  13. package/.github/skills/testdriver:device-config/SKILL.md +317 -0
  14. package/.github/skills/testdriver:double-click/SKILL.md +102 -0
  15. package/.github/skills/testdriver:elements/SKILL.md +605 -0
  16. package/.github/skills/testdriver:enterprise/SKILL.md +114 -0
  17. package/.github/skills/testdriver:examples/SKILL.md +7 -0
  18. package/.github/skills/testdriver:exec/SKILL.md +345 -0
  19. package/.github/skills/testdriver:find/SKILL.md +721 -0
  20. package/.github/skills/testdriver:focus-application/SKILL.md +293 -0
  21. package/.github/skills/testdriver:generating-tests/SKILL.md +36 -0
  22. package/.github/skills/testdriver:hover/SKILL.md +278 -0
  23. package/.github/skills/testdriver:locating-elements/SKILL.md +71 -0
  24. package/.github/skills/testdriver:making-assertions/SKILL.md +32 -0
  25. package/.github/skills/testdriver:mcp-workflow/SKILL.md +410 -0
  26. package/.github/skills/testdriver:mouse-down/SKILL.md +161 -0
  27. package/.github/skills/testdriver:mouse-up/SKILL.md +164 -0
  28. package/.github/skills/testdriver:performing-actions/SKILL.md +51 -0
  29. package/.github/skills/testdriver:press-keys/SKILL.md +348 -0
  30. package/.github/skills/testdriver:quickstart/SKILL.md +161 -0
  31. package/.github/skills/testdriver:reusable-code/SKILL.md +240 -0
  32. package/.github/skills/testdriver:right-click/SKILL.md +123 -0
  33. package/.github/skills/testdriver:running-tests/SKILL.md +181 -0
  34. package/.github/skills/testdriver:screenshot/SKILL.md +167 -0
  35. package/.github/skills/testdriver:scroll/SKILL.md +299 -0
  36. package/.github/skills/testdriver:secrets/SKILL.md +115 -0
  37. package/.github/skills/testdriver:self-hosted/SKILL.md +65 -0
  38. package/.github/skills/testdriver:test-writer/SKILL.md +451 -0
  39. package/.github/skills/testdriver:testdriver/SKILL.md +523 -0
  40. package/.github/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
  41. package/.github/skills/testdriver:type/SKILL.md +357 -0
  42. package/.github/skills/testdriver:variables/SKILL.md +111 -0
  43. package/.github/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
  44. package/.github/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  45. package/.github/workflows/acceptance-windows-scheduled.yaml +6 -1
  46. package/.github/workflows/acceptance.yaml +0 -36
  47. package/.github/workflows/update-examples.yaml +53 -0
  48. package/CHANGELOG.md +4 -0
  49. package/agent/events.js +1 -0
  50. package/agent/index.js +8 -0
  51. package/agent/lib/commands.js +48 -29
  52. package/agent/lib/redraw.js +3 -1
  53. package/agent/lib/sandbox.js +166 -14
  54. package/agent/lib/sdk.js +142 -3
  55. package/agent/lib/system.js +4 -6
  56. package/ai/skills/testdriver:ai/SKILL.md +204 -0
  57. package/ai/skills/testdriver:assert/SKILL.md +315 -0
  58. package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
  59. package/ai/skills/testdriver:caching/SKILL.md +124 -0
  60. package/ai/skills/testdriver:captcha/SKILL.md +159 -0
  61. package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
  62. package/ai/skills/testdriver:click/SKILL.md +286 -0
  63. package/ai/skills/testdriver:client/SKILL.md +372 -0
  64. package/ai/skills/testdriver:cloud/SKILL.md +119 -0
  65. package/ai/skills/testdriver:customizing-devices/SKILL.md +153 -0
  66. package/ai/skills/testdriver:dashcam/SKILL.md +418 -0
  67. package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +401 -0
  68. package/ai/skills/testdriver:device-config/SKILL.md +317 -0
  69. package/ai/skills/testdriver:double-click/SKILL.md +102 -0
  70. package/ai/skills/testdriver:elements/SKILL.md +605 -0
  71. package/ai/skills/testdriver:enterprise/SKILL.md +114 -0
  72. package/ai/skills/testdriver:examples/SKILL.md +7 -0
  73. package/ai/skills/testdriver:exec/SKILL.md +345 -0
  74. package/ai/skills/testdriver:find/SKILL.md +745 -0
  75. package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
  76. package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
  77. package/ai/skills/testdriver:hover/SKILL.md +278 -0
  78. package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
  79. package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
  80. package/ai/skills/testdriver:mcp-workflow/SKILL.md +410 -0
  81. package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
  82. package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
  83. package/ai/skills/testdriver:ocr/SKILL.md +235 -0
  84. package/ai/skills/testdriver:performing-actions/SKILL.md +51 -0
  85. package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
  86. package/ai/skills/testdriver:quickstart/SKILL.md +146 -0
  87. package/ai/skills/testdriver:reusable-code/SKILL.md +240 -0
  88. package/ai/skills/testdriver:right-click/SKILL.md +123 -0
  89. package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
  90. package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
  91. package/ai/skills/testdriver:scroll/SKILL.md +335 -0
  92. package/ai/skills/testdriver:secrets/SKILL.md +115 -0
  93. package/ai/skills/testdriver:self-hosted/SKILL.md +65 -0
  94. package/ai/skills/testdriver:test-writer/SKILL.md +451 -0
  95. package/ai/skills/testdriver:testdriver/SKILL.md +631 -0
  96. package/ai/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
  97. package/ai/skills/testdriver:type/SKILL.md +357 -0
  98. package/ai/skills/testdriver:variables/SKILL.md +111 -0
  99. package/ai/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
  100. package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  101. package/debugger/index.html +12 -2
  102. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  103. package/docs/v7/find.mdx +1 -0
  104. package/examples/config.mjs +1 -1
  105. package/examples/findall-coffee-icons.test.mjs +42 -0
  106. package/examples/flake-diffthreshold-001.test.mjs +9 -0
  107. package/examples/flake-diffthreshold-01.test.mjs +9 -0
  108. package/examples/flake-diffthreshold-05.test.mjs +9 -0
  109. package/examples/{z_flake-noredraw-cache.test.mjs → flake-noredraw-cache.test.mjs} +2 -2
  110. package/examples/{z_flake-noredraw-nocache.test.mjs → flake-noredraw-nocache.test.mjs} +2 -2
  111. package/examples/{z_flake-redraw-cache.test.mjs → flake-redraw-cache.test.mjs} +2 -2
  112. package/examples/{z_flake-redraw-nocache.test.mjs → flake-redraw-nocache.test.mjs} +2 -2
  113. package/examples/flake-rocket-match.test.mjs +30 -0
  114. package/examples/{z_flake-shared.mjs → flake-shared.mjs} +2 -2
  115. package/examples/parse.test.mjs +19 -0
  116. package/examples/scroll-keyboard.test.mjs +1 -1
  117. package/interfaces/cli/lib/base.js +6 -0
  118. package/interfaces/logger.js +51 -13
  119. package/interfaces/vitest-plugin.mjs +137 -0
  120. package/lib/core/index.d.ts +22 -0
  121. package/lib/init-project.js +105 -6
  122. package/lib/vitest/hooks.mjs +2 -5
  123. package/lib/vitest/setup-disable-defender.mjs +52 -0
  124. package/package.json +2 -1
  125. package/sdk-log-formatter.js +90 -0
  126. package/sdk.d.ts +88 -51
  127. package/sdk.js +126 -18
  128. package/setup/aws/disable-defender.sh +42 -0
  129. package/vitest.config.mjs +1 -3
  130. package/examples/z_flake-diffthreshold-001.test.mjs +0 -9
  131. package/examples/z_flake-diffthreshold-01.test.mjs +0 -9
  132. package/examples/z_flake-diffthreshold-05.test.mjs +0 -9
  133. /package/{examples → manual}/captcha-api.test.mjs +0 -0
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: testdriver:quickstart
3
+ description: Run your first computer-use test in minutes.
4
+ ---
5
+ <!-- Generated from quickstart.mdx. DO NOT EDIT. -->
6
+
7
+ TestDriver makes it easy to write automated computer-use tests for web browsers, desktop apps, and more. Follow the directions below to run your first TestDriver test.
8
+
9
+ <Tip><a href="https://discord.com/invite/cWDFW8DzPm" target="_blank" rel="noreferrer">Join our Discord</a> if you have any questions or need help getting started!</Tip>
10
+
11
+ <Tabs>
12
+ <Tab title="Automatic Setup">
13
+
14
+ Get started quickly with the TestDriver CLI.
15
+
16
+ <Steps>
17
+ <Step title="Create a TestDriver Account">
18
+
19
+ You will need a TestDriver account to get an API key.
20
+
21
+ <Card
22
+ title="Get an API Key"
23
+ icon="user-plus"
24
+ href="https://console.testdriver.ai/team"
25
+ arrow
26
+ horizontal
27
+ >
28
+ Start with 60 free device minutes, no credit-card required!
29
+ </Card>
30
+
31
+ </Step>
32
+ <Step title="Install TestDriver">
33
+
34
+ Use `npx` to quickly set up an example project:
35
+
36
+ ```bash
37
+ npx testdriverai@beta init
38
+ ```
39
+
40
+ This will walk you through creating a new project folder, installing dependencies, and setting up your API key.
41
+
42
+ </Step>
43
+
44
+ <Step title="Run Your Test">
45
+
46
+ TestDriver uses Vitest as the test runner. To run your test, use:
47
+
48
+ ```bash
49
+ vitest run
50
+ ```
51
+
52
+ This will spawn a sandbox, launch Chrome, and run the example test!
53
+
54
+ </Step>
55
+ </Steps>
56
+ </Tab>
57
+ <Tab title="Manual Setup">
58
+
59
+ Install TestDriver and manually create the files yourself.
60
+
61
+ <Steps>
62
+ <Step title="Create a TestDriver Account">
63
+
64
+ You will need a TestDriver account to get an API key.
65
+
66
+ <Card
67
+ title="Get an API Key"
68
+ icon="user-plus"
69
+ href="https://console.testdriver.ai/team"
70
+ arrow
71
+ horizontal
72
+ >
73
+ Start with 60 free device minutes, no credit-card required!
74
+ </Card>
75
+
76
+ </Step>
77
+ <Step title="Install Dependencies">
78
+
79
+ Install Vitest and TestDriver as dev dependencies:
80
+
81
+ ```bash
82
+ npm install --save-dev vitest testdriverai@beta
83
+ ```
84
+
85
+ </Step>
86
+ <Step title="Create a vitest.config.js File">
87
+
88
+ In your project root, create a `vitest.config.js` file with the following content:
89
+
90
+ ```js vitest.config.js
91
+ import TestDriver from 'testdriverai/vitest';
92
+ import { defineConfig } from 'vitest/config';
93
+
94
+ export default defineConfig({
95
+ test: {
96
+ testTimeout: 900000,
97
+ hookTimeout: 900000,
98
+ disableConsoleIntercept: true,
99
+ maxConcurrency: 1, // this should match your plan's concurrency limit
100
+ reporters: [
101
+ 'default',
102
+ TestDriver()
103
+ ],
104
+ setupFiles: ['testdriverai/vitest/setup'],
105
+ },
106
+ });
107
+ ```
108
+
109
+ </Step>
110
+ <Step title="Create an Example Test File">
111
+
112
+ Add your API key to the example test file below and save it as `test.mjs` in your project root.
113
+
114
+ ```js test.mjs highlight={9}
115
+ import { describe, expect, it } from "vitest";
116
+ // Import TestDriver from the vitest hooks
117
+ import { TestDriver } from "testdriverai/vitest/hooks";
118
+
119
+ describe("Google Search Example", () => {
120
+ it("should search for TestDriver", async (context) => {
121
+ // Create TestDriver instance - automatically connects to sandbox
122
+ const testdriver = TestDriver(context, {
123
+ apiKey: 'YOUR_API_KEY_HERE' // supply your API key here
124
+ });
125
+
126
+ // Provision Chrome browser with a URL
127
+ // This also starts dashcam recording automatically
128
+ await testdriver.provision.chrome({ url: "https://duckduckgo.com" });
129
+
130
+ // Find and interact with elements using natural language
131
+ const searchBox = await testdriver.find("DuckDuckGo search input field");
132
+ await searchBox.click();
133
+
134
+ // Type into the focused element
135
+ await testdriver.type("testdriver.ai");
136
+
137
+ // Press Enter to search
138
+ await testdriver.pressKeys(["enter"]);
139
+
140
+ // Assert something is visible on the page
141
+ const result = await testdriver.assert("search results are displayed");
142
+ expect(result).toBeTruthy();
143
+ });
144
+ });
145
+ ```
146
+
147
+ </Step>
148
+ <Step title="Run Your Test">
149
+
150
+ TestDriver uses Vitest as the test runner. To run your test, use:
151
+
152
+ ```bash
153
+ vitest run
154
+ ```
155
+
156
+ This will spawn a sandbox, launch Chrome, and run the example test!
157
+
158
+ </Step>
159
+ </Steps>
160
+ </Tab>
161
+ </Tabs>
@@ -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,181 @@
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
+ ### Run All Tests
14
+
15
+ ```bash
16
+ vitest run
17
+ ```
18
+
19
+ Executes all test files in your project once and exits. Vitest automatically discovers files matching patterns like `*.test.js`, `*.test.mjs`, or `*.spec.js`.
20
+
21
+ ### Run with Coverage
22
+
23
+ ```bash
24
+ vitest run --coverage
25
+ ```
26
+
27
+ 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.
28
+
29
+ <Info>
30
+ Coverage requires the `@vitest/coverage-v8` package. Install it with `npm install -D @vitest/coverage-v8`.
31
+ </Info>
32
+
33
+ ### Run Specific Tests
34
+
35
+ ```bash
36
+ vitest run login.test.js
37
+ ```
38
+
39
+ Runs only the specified test file. Useful when debugging a single test or working on a specific feature.
40
+
41
+ ```bash
42
+ vitest run login.test.js checkout.test.js
43
+ ```
44
+
45
+ Runs multiple specific test files. List as many files as needed, separated by spaces.
46
+
47
+ ### Filter Tests by Name
48
+
49
+ ```bash
50
+ vitest run --grep "login"
51
+ ```
52
+
53
+ 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.
54
+
55
+ ### Run Tests in a Folder
56
+
57
+ ```bash
58
+ vitest run tests/e2e/
59
+ ```
60
+
61
+ Runs all test files within a specific directory. Great for organizing tests by type (unit, integration, e2e) and running them separately.
62
+
63
+ ## Parallel Execution
64
+
65
+ TestDriver runs each test in its own cloud sandbox, enabling true parallel execution. Run your entire test suite in minutes instead of hours.
66
+
67
+ ### Control Concurrency
68
+
69
+ ```bash
70
+ vitest run --maxConcurrency=5
71
+ ```
72
+
73
+ The `--maxConcurrency` flag limits how many tests run simultaneously. This should match your TestDriver license slots to avoid failures from exhausted slots.
74
+
75
+ ### Thread Configuration
76
+
77
+ ```bash
78
+ vitest run --pool=threads --minThreads=2 --maxThreads=8
79
+ ```
80
+
81
+ Fine-tune thread allocation for optimal performance:
82
+ - `--pool=threads` — Uses worker threads for test isolation
83
+ - `--minThreads` — Minimum number of threads to keep alive (reduces startup overhead)
84
+ - `--maxThreads` — Maximum threads to spawn (limits resource usage)
85
+
86
+ ### License Slots
87
+
88
+ 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.
89
+
90
+ <Info>
91
+ View your available slots at [console.testdriver.ai](https://console.testdriver.ai). Upgrade anytime to increase parallelization.
92
+ </Info>
93
+
94
+ ### Configuring Concurrency
95
+
96
+ Set `maxConcurrency` in your Vitest config to match your license slot limit:
97
+
98
+ ```javascript vitest.config.mjs
99
+ import { defineConfig } from 'vitest/config';
100
+ import { TestDriver } from 'testdriverai/vitest';
101
+
102
+ export default defineConfig({
103
+ test: {
104
+ testTimeout: 900000,
105
+ hookTimeout: 900000,
106
+ maxConcurrency: 5, // Match your license slot limit
107
+ reporters: ['default', TestDriver()],
108
+ setupFiles: ['testdriverai/vitest/setup'],
109
+ },
110
+ });
111
+ ```
112
+
113
+ <Warning>
114
+ 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.
115
+ </Warning>
116
+
117
+ ### Why Parallelization Matters
118
+
119
+ | Test Suite | Sequential (1 slot) | Parallel (5 slots) | Parallel (10 slots) |
120
+ |------------|--------------------|--------------------|---------------------|
121
+ | 10 tests @ 2min each | 20 min | 4 min | 2 min |
122
+ | 50 tests @ 2min each | 100 min | 20 min | 10 min |
123
+ | 100 tests @ 2min each | 200 min | 40 min | 20 min |
124
+
125
+ <Tip>
126
+ **Pro tip:** Upgrading your plan doesn't just increase speed—it enables faster CI/CD feedback loops, letting your team ship with confidence.
127
+ </Tip>
128
+
129
+ <Card
130
+ title="View Plans & Pricing"
131
+ icon="credit-card"
132
+ href="/v7/cloud"
133
+ >
134
+ Compare plans and find the right level of parallelization for your team.
135
+ </Card>
136
+
137
+ ## Vitest UI
138
+
139
+ Use Vitest UI for interactive debugging:
140
+
141
+ ```bash
142
+ vitest --ui
143
+ ```
144
+
145
+ The `--ui` flag launches a web-based interface for managing your test suite. Unlike `vitest run`, this starts in watch mode by default.
146
+
147
+ Open http://localhost:51204 to see:
148
+ - **Test file tree** — Browse and navigate your test structure
149
+ - **Test status and duration** — See pass/fail states and timing at a glance
150
+ - **Console output** — View logs and errors inline with each test
151
+ - **Re-run individual tests** — Click to re-execute specific tests without restarting
152
+ - **Filter and search** — Quickly find tests by name or status
153
+
154
+ <Tip>
155
+ Combine with `--open` to automatically open the UI in your browser: `vitest --ui --open`
156
+ </Tip>
157
+
158
+
159
+ ## Test Reports
160
+
161
+ After running tests, view detailed reports and video replays at [console.testdriver.ai](https://console.testdriver.ai).
162
+
163
+ Reports include:
164
+ - **Video replays** - Watch exactly what happened during each test
165
+ - **Screenshots** - See the state at each step
166
+ - **Timing breakdown** - Identify slow operations
167
+ - **Error details** - Debug failures with full context
168
+
169
+ ```bash
170
+ $ vitest run
171
+
172
+ ✓ login.test.js (2) 18.4s
173
+ ✓ user can login 12.3s
174
+ ✓ shows error for invalid credentials 6.1s
175
+
176
+ 📹 View reports at: https://console.testdriver.ai
177
+ ```
178
+
179
+ <Tip>
180
+ Bookmark your team's dashboard at [console.testdriver.ai](https://console.testdriver.ai) for quick access to test history and analytics.
181
+ </Tip>