@testdriverai/agent 7.11.240-test → 7.11.241-test

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 (52) hide show
  1. package/ai/skills/testdriver-agent/SKILL.md +174 -91
  2. package/ai/skills/testdriver-assert/SKILL.md +73 -269
  3. package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
  4. package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
  5. package/ai/skills/testdriver-cache/SKILL.md +142 -149
  6. package/ai/skills/testdriver-caching/SKILL.md +97 -87
  7. package/ai/skills/testdriver-captcha/SKILL.md +126 -111
  8. package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
  9. package/ai/skills/testdriver-click/SKILL.md +74 -229
  10. package/ai/skills/testdriver-client/SKILL.md +175 -229
  11. package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
  12. package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
  13. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
  14. package/ai/skills/testdriver-double-click/SKILL.md +46 -67
  15. package/ai/skills/testdriver-errors/SKILL.md +102 -176
  16. package/ai/skills/testdriver-events/SKILL.md +170 -327
  17. package/ai/skills/testdriver-exec/SKILL.md +92 -256
  18. package/ai/skills/testdriver-extract/SKILL.md +69 -170
  19. package/ai/skills/testdriver-find/SKILL.md +140 -736
  20. package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
  22. package/ai/skills/testdriver-hosted/SKILL.md +79 -143
  23. package/ai/skills/testdriver-hover/SKILL.md +62 -235
  24. package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
  25. package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
  26. package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
  27. package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
  28. package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
  29. package/ai/skills/testdriver-options/SKILL.md +73 -46
  30. package/ai/skills/testdriver-parse/SKILL.md +95 -184
  31. package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
  32. package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
  33. package/ai/skills/testdriver-provision/SKILL.md +135 -179
  34. package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
  35. package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
  36. package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
  37. package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
  38. package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
  39. package/ai/skills/testdriver-redraw/SKILL.md +100 -164
  40. package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
  41. package/ai/skills/testdriver-right-click/SKILL.md +45 -88
  42. package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
  43. package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
  44. package/ai/skills/testdriver-scroll/SKILL.md +71 -154
  45. package/ai/skills/testdriver-secrets/SKILL.md +94 -90
  46. package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
  47. package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
  48. package/ai/skills/testdriver-type/SKILL.md +56 -304
  49. package/ai/skills/testdriver-variables/SKILL.md +119 -80
  50. package/ai/skills/testdriver-wait/SKILL.md +31 -29
  51. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
  52. package/package.json +1 -1
@@ -1,322 +1,268 @@
1
1
  ---
2
2
  name: testdriver:client
3
- description: Create the TestDriver client, authenticate, and connect to a sandbox
3
+ description: Create a TestDriver client, connect it to a sandbox, and disconnect when you're done.
4
4
  ---
5
5
  <!-- Generated from client.mdx. DO NOT EDIT. -->
6
6
 
7
- ## Overview
7
+ import { EnterpriseBadge, EnterpriseCta } from '/snippets/enterprise.mdx';
8
8
 
9
- The `TestDriver` client is the main entry point for the SDK. It does the authentication and the sandbox connection. It gives access to all test methods.
9
+ Every test talks to its sandbox through a TestDriver client. There are two ways to create one:
10
10
 
11
- ## Constructor
11
+ - **`TestDriver(context)`** from `testdriverai/vitest/hooks`. Use this in Vitest tests. It connects and disconnects for you.
12
+ - **`new TestDriver()`** from `testdriverai`. Use this outside Vitest's per-test hooks, when you manage the connection yourself.
12
13
 
13
14
  ```javascript
14
- const testdriver = new TestDriver(apiKey, options)
15
+ import { TestDriver } from 'testdriverai/vitest/hooks';
16
+
17
+ test('opens the login page', async (context) => {
18
+ const testdriver = TestDriver(context);
19
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
20
+ });
21
+ ```
22
+
23
+ ## TestDriver(context, options)
24
+
25
+ Creates a client for the current Vitest test.
26
+
27
+ ```typescript
28
+ TestDriver(context: TestContext, options?: TestDriverOptions): TestDriver
15
29
  ```
16
30
 
17
31
  ### Parameters
18
32
 
19
- <ParamField path="apiKey" type="string" required>
20
- Your TestDriver API key from the [dashboard](https://console.testdriver.ai/settings)
33
+ <ParamField path="context" type="TestContext" required>
34
+ The context Vitest passes to your test function, as in `async (context) => { ... }`. TestDriver throws if it's missing.
21
35
  </ParamField>
22
36
 
23
- <ParamField path="options" type="object">
24
- The configuration options for the client. See [SDK Options](/options) for the full list, with defaults and examples for each option.
37
+ <ParamField path="options" type="TestDriverOptions">
38
+ Client options, such as `os`, `preview`, `cache`, or `keepAlive`. See [Options](/options) for the full list.
39
+
40
+ <Expandable title="hook-only options">
41
+ <ParamField path="apiKey" type="string">
42
+ Your TestDriver API key. Defaults to the `TD_API_KEY` environment variable, which TestDriver also loads from `.env`.
43
+ </ParamField>
44
+ <ParamField path="debugOnFailure" type="boolean" default="false">
45
+ If the test fails, keep its sandbox running instead of disconnecting, and print the sandbox id so you can reconnect to it.
46
+ </ParamField>
47
+ </Expandable>
25
48
  </ParamField>
26
49
 
27
- ### Example
50
+ ### What it does
28
51
 
29
- ```javascript
30
- import TestDriver from 'testdriverai';
52
+ - **Connects automatically.** It authenticates and connects to a sandbox in the background. Your first command waits for the connection.
53
+ - **Disconnects automatically** when the test finishes.
54
+ - **Returns one client per test.** Calling it again in the same test returns the same client. A retried test gets a new one.
55
+ - **Reads `TD_OS`.** If you don't pass `os`, it uses the `TD_OS` environment variable, then Linux.
31
56
 
32
- // API key is automatically loaded from TD_API_KEY in .env
33
- const testdriver = new TestDriver({
34
- os: 'windows',
35
- resolution: '1920x1080',
36
- logging: true,
37
- analytics: true
38
- });
57
+ ### Returns
39
58
 
40
- // With AI config for stricter verification
41
- const testdriver = new TestDriver({
42
- ai: { temperature: 0, top: { p: 0.9, k: 40 } }
43
- });
59
+ A connected `TestDriver` client.
44
60
 
45
- // Or pass API key explicitly
46
- const testdriver = new TestDriver('your-api-key', {
47
- os: 'windows'
48
- });
61
+ ## new TestDriver(apiKey, options)
62
+
63
+ Creates a client that you connect and disconnect yourself.
64
+
65
+ ```typescript
66
+ new TestDriver(apiKey?: string, options?: TestDriverOptions)
67
+ new TestDriver(options?: TestDriverOptions)
49
68
  ```
50
69
 
51
- ## Authentication
70
+ ### Parameters
52
71
 
53
- ### auth()
72
+ <ParamField path="apiKey" type="string">
73
+ Your TestDriver API key. Defaults to `TD_API_KEY`, which TestDriver loads from `.env`. Create one at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys).
74
+ </ParamField>
54
75
 
55
- Authenticate with the TestDriver API.
76
+ <ParamField path="options" type="TestDriverOptions">
77
+ Client options. See [Options](/options).
78
+ </ParamField>
56
79
 
57
- ```javascript
58
- await testdriver.auth()
59
- ```
80
+ ### Example
60
81
 
61
- **Returns:** `Promise<string>` - Authentication token
82
+ Share one sandbox across a test file by connecting in `beforeAll`:
62
83
 
63
- **Example:**
64
- ```javascript
65
- await testdriver.auth();
66
- ```
84
+ ```javascript tests/dashboard.test.mjs
85
+ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
86
+ import TestDriver from 'testdriverai';
67
87
 
68
- <Note>
69
- You must call `auth()` before `connect()`. Most examples call both sequentially.
70
- </Note>
88
+ describe('Dashboard', () => {
89
+ let testdriver;
71
90
 
72
- ## Connection Management
91
+ beforeAll(async () => {
92
+ testdriver = new TestDriver({ os: 'linux' });
93
+ await testdriver.connect();
94
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
95
+ });
73
96
 
74
- ### connect()
97
+ afterAll(async () => {
98
+ await testdriver.disconnect();
99
+ });
75
100
 
76
- Connect to a sandbox environment. This creates or reconnects to a virtual machine where your tests will run.
101
+ it('shows the login form', async () => {
102
+ const result = await testdriver.assert('a login form is visible');
103
+ expect(result).toBe(true);
104
+ });
105
+ });
106
+ ```
77
107
 
78
- ```javascript
79
- await testdriver.connect(options)
108
+ ## connect(options)
109
+
110
+ Connects the client to a sandbox. By default, it creates a new sandbox.
111
+
112
+ ```typescript
113
+ testdriver.connect(options?: ConnectOptions): Promise<SandboxInstance>
80
114
  ```
81
115
 
82
- #### Parameters
116
+ `connect()` authenticates first if needed. You don't need to call `auth()` yourself.
83
117
 
84
- <ParamField path="options" type="object">
85
- Connection options
86
-
118
+ ### Parameters
119
+
120
+ <ParamField path="options" type="ConnectOptions">
87
121
  <Expandable title="properties">
88
- <ParamField path="newSandbox" type="boolean" default="false">
89
- Force creation of a new sandbox instead of reusing an existing one
90
- </ParamField>
91
-
92
122
  <ParamField path="sandboxId" type="string">
93
- Existing sandbox ID to reconnect to
123
+ Reconnect to this existing sandbox instead of creating one.
124
+ </ParamField>
125
+ <ParamField path="requireSandbox" type="boolean" default="false">
126
+ With `sandboxId`, throw if that sandbox is gone, instead of creating a new, empty one in its place.
127
+ </ParamField>
128
+ <ParamField path="reconnect" type="boolean">
129
+ Reconnect to the last sandbox this project used, recorded in `.testdriver/last-sandbox`. Provision calls are skipped, because the app is already running. Throws if there's no previous sandbox.
130
+ </ParamField>
131
+ <ParamField path="newSandbox" type="boolean" default="true">
132
+ Create a new sandbox. Set to `false` when you pass `sandboxId` or `reconnect`.
133
+ </ParamField>
134
+ <ParamField path="keepAlive" type="number" default="60000">
135
+ Milliseconds to keep the sandbox running after `disconnect()`, so you can reconnect. Capped at 30 minutes. `0` uses the default.
136
+ </ParamField>
137
+ <ParamField path="os" type="string" default="linux">
138
+ `"linux"` or `"windows"`. <EnterpriseBadge /> Windows is available on Enterprise plans.
139
+ </ParamField>
140
+ <ParamField path="preview" type="string" default="browser">
141
+ Where to show the live run: `"browser"`, `"ide"` (needs the TestDriver extension), or `"none"`.
142
+ </ParamField>
143
+ <ParamField path="reuseConnection" type="boolean" default="true">
144
+ Reuse a recent connection if one is available.
94
145
  </ParamField>
95
-
96
146
  <ParamField path="ip" type="string">
97
- Direct IP address to connect to (for self-hosted sandboxes)
147
+ Connect directly to a running sandbox at this IP address, for self-hosted machines. <EnterpriseBadge />
98
148
  </ParamField>
99
-
100
149
  <ParamField path="sandboxAmi" type="string">
101
- AMI to use for the sandbox (AWS deployments)
150
+ Custom AMI ID for the sandbox, for self-hosted AWS deployments. <EnterpriseBadge />
102
151
  </ParamField>
103
-
104
152
  <ParamField path="sandboxInstance" type="string">
105
- Instance type for the sandbox (AWS deployments)
153
+ EC2 instance type for the sandbox, for self-hosted AWS deployments. <EnterpriseBadge />
106
154
  </ParamField>
107
-
108
- <ParamField path="preview" type="string" default="browser">
109
- Preview mode for live test visualization:
110
- - `"browser"` - Opens debugger in default browser (default)
111
- - `"ide"` - Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
112
- - `"none"` - Headless mode, no visual preview
155
+ <ParamField path="e2bTemplateId" type="string">
156
+ E2B template ID to create the sandbox from.
113
157
  </ParamField>
114
-
115
158
  <ParamField path="headless" type="boolean" default="false">
116
- **Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
117
- </ParamField>
118
-
119
- <ParamField path="keepAlive" type="number" default="60000">
120
- Keep sandbox alive for the specified number of milliseconds after disconnect. Set to `0` to terminate immediately on disconnect. Useful for debugging or reconnecting to the same sandbox.
159
+ Deprecated. Use `preview: "none"` instead.
121
160
  </ParamField>
122
161
  </Expandable>
123
162
  </ParamField>
124
163
 
125
- **Returns:** `Promise&lt;Object&gt;` - Sandbox instance details including `instanceId`, `ip`, `vncPort`, etc.
164
+ ### Returns
126
165
 
127
- #### Examples
128
-
129
- **Basic connection:**
130
- ```javascript
131
- await testdriver.connect();
132
- ```
133
-
134
- **Reconnect to existing sandbox:**
135
- ```javascript
136
- const instance = await testdriver.connect({
137
- sandboxId: 'existing-sandbox-id-123'
138
- });
139
- ```
166
+ <ResponseField name="SandboxInstance" type="object">
167
+ <Expandable title="properties">
168
+ <ResponseField name="instanceId" type="string">
169
+ The sandbox's ID.
170
+ </ResponseField>
171
+ <ResponseField name="ip" type="string">
172
+ The sandbox's IP address.
173
+ </ResponseField>
174
+ <ResponseField name="vncPort" type="number">
175
+ The port for the sandbox's remote display.
176
+ </ResponseField>
177
+ </Expandable>
178
+ </ResponseField>
140
179
 
141
- **Self-hosted sandbox:**
142
- ```javascript
143
- await testdriver.connect({
144
- ip: '192.168.1.100'
145
- });
146
- ```
180
+ ### Errors
147
181
 
148
- ### disconnect()
182
+ Throws `Already connected` if the client is already connected. Create a new client to connect again.
149
183
 
150
- Disconnect from the sandbox and clean up resources.
184
+ ### Example
151
185
 
152
186
  ```javascript
153
- await testdriver.disconnect()
187
+ const testdriver = new TestDriver();
188
+
189
+ // Reattach to a sandbox you kept alive earlier
190
+ const sandbox = await testdriver.connect({ sandboxId: 'sandbox-abc123', newSandbox: false });
191
+ console.log(sandbox.instanceId);
154
192
  ```
155
193
 
156
- **Returns:** `Promise<void>`
194
+ ## disconnect()
157
195
 
158
- **Example:**
159
- ```javascript
160
- afterAll(async () => {
161
- await testdriver.disconnect();
162
- });
196
+ Disconnects from the sandbox. The sandbox keeps running for the `keepAlive` time, then shuts down.
197
+
198
+ ```typescript
199
+ testdriver.disconnect(): Promise<void>
163
200
  ```
164
201
 
165
- ## Instance Information
202
+ The Vitest hook calls this for you.
166
203
 
167
- ### getInstance()
204
+ ## auth()
168
205
 
169
- Get the current sandbox instance details.
206
+ Authenticates with the TestDriver API and resolves to a session token.
170
207
 
171
- ```javascript
172
- const instance = testdriver.getInstance()
208
+ ```typescript
209
+ testdriver.auth(): Promise<string>
173
210
  ```
174
211
 
175
- **Returns:** `Object | null` - Sandbox instance information
212
+ You rarely need it, because `connect()` calls it when needed.
176
213
 
177
- **Example:**
178
- ```javascript
179
- const instance = testdriver.getInstance();
180
- console.log('Instance ID:', instance.instanceId);
181
- console.log('IP Address:', instance.ip);
182
- ```
183
-
184
- ### getSessionId()
214
+ ## getInstance()
185
215
 
186
- Get the current session ID for tracking and debugging.
216
+ Returns the connected sandbox's details, or `null` if the client isn't connected.
187
217
 
188
- ```javascript
189
- const sessionId = testdriver.getSessionId()
218
+ ```typescript
219
+ testdriver.getInstance(): SandboxInstance | null
190
220
  ```
191
221
 
192
- **Returns:** `string | null` - Session ID
222
+ ## getSessionId()
193
223
 
194
- **Example:**
195
- ```javascript
196
- const sessionId = testdriver.getSessionId();
197
- console.log('Session:', sessionId);
198
- ```
224
+ Returns the current session ID, or `null`. Include it when you report a problem.
199
225
 
200
- ## Logging & Events
226
+ ```typescript
227
+ testdriver.getSessionId(): string | null
228
+ ```
201
229
 
202
- ### setLogging()
230
+ ## getLastSandboxId()
203
231
 
204
- Enable or disable console logging at runtime.
232
+ Returns the most recent sandbox, or `null` if there isn't one. It reads from the connected client, or from `.testdriver/last-sandbox`.
205
233
 
206
- ```javascript
207
- testdriver.setLogging(enabled)
234
+ ```typescript
235
+ testdriver.getLastSandboxId(): { sandboxId: string; os?: 'windows' | 'linux'; createdAt?: number } | null
208
236
  ```
209
237
 
210
- **Parameters:**
211
- - `enabled` (boolean) - Whether to enable logging
238
+ ## setLogging(enabled)
212
239
 
213
- **Example:**
214
- ```javascript
215
- // Disable logging for cleanup operations
216
- testdriver.setLogging(false);
217
- await testdriver.disconnect();
218
- testdriver.setLogging(true);
240
+ Turns console logging on or off while the test runs.
241
+
242
+ ```typescript
243
+ testdriver.setLogging(enabled: boolean): void
219
244
  ```
220
245
 
221
- ### getEmitter()
246
+ ## getEmitter()
222
247
 
223
- Get the event emitter for custom event handling.
248
+ Returns the client's event emitter, so you can react to what TestDriver does.
224
249
 
225
- ```javascript
226
- const emitter = testdriver.getEmitter()
250
+ ```typescript
251
+ testdriver.getEmitter(): EventEmitter2
227
252
  ```
228
253
 
229
- **Returns:** `EventEmitter2` - Event emitter instance
230
-
231
- **Example:**
232
254
  ```javascript
233
255
  const emitter = testdriver.getEmitter();
234
256
 
235
- emitter.on('command:start', (data) => {
236
- console.log('Command started:', data);
237
- });
238
-
239
- emitter.on('command:success', (data) => {
240
- console.log('Command succeeded:', data);
241
- });
242
-
243
- emitter.on('command:error', (error) => {
244
- console.error('Command failed:', error);
245
- });
257
+ emitter.on('log:warn', (message) => console.warn('TestDriver warning:', message));
258
+ emitter.on('error:sdk', (error) => console.error('TestDriver API error:', error.message));
246
259
  ```
247
260
 
248
- ## Complete Example
249
-
250
- ```javascript
251
- import { beforeAll, afterAll, describe, it } from 'vitest';
252
- import TestDriver from 'testdriverai';
253
-
254
- describe('My Test Suite', () => {
255
- let testdriver;
261
+ See [Events](/events) for every event name.
256
262
 
257
- beforeAll(async () => {
258
- // Initialize client - API key loaded automatically from .env
259
- testdriver = new TestDriver({
260
- os: 'windows',
261
- resolution: '1366x768',
262
- logging: true
263
- });
264
-
265
- // Set up event listeners
266
- const emitter = testdriver.getEmitter();
267
- emitter.on('log:info', (msg) => console.log('[INFO]', msg));
268
-
269
- // Authenticate and connect
270
- await testdriver.auth();
271
- const instance = await testdriver.connect();
272
-
273
- console.log('Connected to sandbox:', instance.instanceId);
274
- });
275
-
276
- afterAll(async () => {
277
- await testdriver.disconnect();
278
- });
279
-
280
- it('runs a test', async () => {
281
- // Your test code here
282
- });
283
- });
284
- ```
263
+ ## Related
285
264
 
286
- ## Best Practices
287
-
288
- <AccordionGroup>
289
- <Accordion title="Reuse sandboxes across tests">
290
- Use `beforeAll`/`afterAll` to create one sandbox per test suite rather than per test. This significantly reduces execution time.
291
- </Accordion>
292
-
293
- <Accordion title="Handle connection errors gracefully">
294
- Wrap `connect()` in a try-catch block to handle network issues or quota limits:
295
-
296
- ```javascript
297
- try {
298
- await testdriver.connect();
299
- } catch (error) {
300
- console.error('Failed to connect:', error.message);
301
- throw error;
302
- }
303
- ```
304
- </Accordion>
305
-
306
- <Accordion title="Always disconnect">
307
- Use `afterAll` or try-finally blocks to ensure `disconnect()` is called even if tests fail. This prevents orphaned sandboxes.
308
- </Accordion>
309
-
310
- <Accordion title="Use environment variables for API keys">
311
- Never hardcode API keys. The SDK automatically loads `TD_API_KEY` from your `.env` file:
312
-
313
- ```bash .env
314
- TD_API_KEY=your_api_key_here
315
- ```
316
-
317
- ```javascript
318
- // API key is loaded automatically - no need to pass it!
319
- const testdriver = new TestDriver();
320
- ```
321
- </Accordion>
322
- </AccordionGroup>
265
+ - [Options](/options): every option you can pass to the client
266
+ - [Launch apps](/provision): start Chrome, extensions, and desktop apps once connected
267
+ - [Run tests](/copilot/running-tests#reuse-a-sandbox-while-you-iterate): reuse a sandbox between runs
268
+ - [Events](/events): listen for commands, logs, and errors