@testdriverai/mcp 7.11.136-test → 7.11.138-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.
- package/ai/skills/testdriver-assert/SKILL.md +5 -5
- package/ai/skills/testdriver-caching/SKILL.md +2 -2
- package/ai/skills/testdriver-changelog/SKILL.md +186 -0
- package/ai/skills/testdriver-claude-mcp-plugin/SKILL.md +208 -0
- package/ai/skills/testdriver-click/SKILL.md +13 -13
- package/ai/skills/testdriver-client/SKILL.md +1 -1
- package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +5 -5
- package/ai/skills/testdriver-double-click/SKILL.md +7 -7
- package/ai/skills/testdriver-enterprise/SKILL.md +1 -1
- package/ai/skills/testdriver-events/SKILL.md +1 -1
- package/ai/skills/testdriver-exec/SKILL.md +10 -10
- package/ai/skills/testdriver-extract/SKILL.md +6 -6
- package/ai/skills/testdriver-find/SKILL.md +61 -61
- package/ai/skills/testdriver-focus-application/SKILL.md +6 -6
- package/ai/skills/testdriver-generating-tests/SKILL.md +3 -3
- package/ai/skills/testdriver-hosted/SKILL.md +3 -3
- package/ai/skills/testdriver-hover/SKILL.md +6 -6
- package/ai/skills/testdriver-making-assertions/SKILL.md +2 -2
- package/ai/skills/testdriver-mouse-down/SKILL.md +9 -9
- package/ai/skills/testdriver-mouse-up/SKILL.md +9 -9
- package/ai/skills/testdriver-parse/SKILL.md +4 -4
- package/ai/skills/testdriver-performing-actions/SKILL.md +4 -4
- package/ai/skills/testdriver-press-keys/SKILL.md +5 -5
- package/ai/skills/testdriver-quickstart/SKILL.md +51 -54
- package/ai/skills/testdriver-redraw/SKILL.md +1 -1
- package/ai/skills/testdriver-right-click/SKILL.md +7 -7
- package/ai/skills/testdriver-screenshot/SKILL.md +9 -9
- package/ai/skills/testdriver-scroll/SKILL.md +13 -13
- package/ai/skills/testdriver-self-hosted/SKILL.md +1 -1
- package/ai/skills/testdriver-type/SKILL.md +7 -7
- package/ai/skills/testdriver-wait/SKILL.md +5 -5
- package/ai/skills/testdriver-what-is-testdriver/SKILL.md +11 -11
- package/docs/{v7/_drafts → _drafts}/agents.mdx +1 -1
- package/docs/{v7/_drafts → _drafts}/best-practices.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/caching-selectors.mdx +3 -3
- package/docs/{v7/_drafts → _drafts}/configuration.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/debugging.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/error-handling.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/faq.mdx +7 -7
- package/docs/{v7/_drafts → _drafts}/installation.mdx +2 -2
- package/docs/{v7/_drafts → _drafts}/migration.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/observable.mdx +3 -3
- package/docs/{v7/_drafts → _drafts}/powerful.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/readme.mdx +11 -11
- package/docs/{v7/_drafts → _drafts}/reports.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/scalable.mdx +10 -10
- package/docs/{v7/_drafts → _drafts}/troubleshooting.mdx +4 -4
- package/docs/{v7/_drafts → _drafts}/vitest-plugin.mdx +2 -2
- package/docs/{v7/_drafts → _drafts}/vitest.mdx +9 -9
- package/docs/_scripts/generate-examples.js +9 -10
- package/docs/_scripts/generate-skills.js +4 -4
- package/docs/{v7/agent.mdx → agent.mdx} +17 -17
- package/docs/{v7/assert.mdx → assert.mdx} +5 -5
- package/docs/{v7/aws-setup.mdx → aws-setup.mdx} +6 -6
- package/docs/{v7/cache.mdx → cache.mdx} +9 -9
- package/docs/{v7/caching.mdx → caching.mdx} +13 -12
- package/docs/{v7/captcha.mdx → captcha.mdx} +7 -7
- package/docs/changelog.mdx +13 -13
- package/docs/{v7/ci-cd.mdx → ci-cd.mdx} +10 -10
- package/docs/{v7/click.mdx → click.mdx} +13 -13
- package/docs/client.mdx +323 -0
- package/docs/{v7/copilot → copilot}/auto-healing.mdx +2 -2
- package/docs/{v7/copilot → copilot}/running-tests.mdx +8 -8
- package/docs/{v7/customizing-devices.mdx → customizing-devices.mdx} +1 -1
- package/docs/{v7/dashcam.mdx → dashcam.mdx} +3 -3
- package/docs/{v7/debugging-with-screenshots.mdx → debugging-with-screenshots.mdx} +12 -12
- package/docs/docs.json +429 -288
- package/docs/{v7/double-click.mdx → double-click.mdx} +7 -7
- package/docs/{v7/elements.mdx → elements.mdx} +7 -7
- package/docs/{v7/enterprise.mdx → enterprise.mdx} +2 -2
- package/docs/{v7/errors.mdx → errors.mdx} +3 -3
- package/docs/{v7/events.mdx → events.mdx} +4 -4
- package/docs/{v7/exec.mdx → exec.mdx} +10 -10
- package/docs/{v7/extract.mdx → extract.mdx} +10 -10
- package/docs/{v7/find.mdx → find.mdx} +61 -61
- package/docs/{v7/focus-application.mdx → focus-application.mdx} +6 -6
- package/docs/{v7/generating-tests.mdx → generating-tests.mdx} +10 -10
- package/docs/guide/best-practices-polling.mdx +6 -1
- package/docs/{v7/hosted.mdx → hosted.mdx} +7 -7
- package/docs/{v7/hover.mdx → hover.mdx} +6 -6
- package/docs/interacting-with-your-app.mdx +198 -0
- package/docs/locating-elements.mdx +423 -0
- package/docs/{v7/making-assertions.mdx → making-assertions.mdx} +7 -7
- package/docs/{v7/mouse-down.mdx → mouse-down.mdx} +9 -9
- package/docs/{v7/mouse-up.mdx → mouse-up.mdx} +9 -9
- package/docs/options.mdx +320 -0
- package/docs/{v7/parse.mdx → parse.mdx} +12 -12
- package/docs/{v7/performing-actions.mdx → performing-actions.mdx} +11 -11
- package/docs/{v7/press-keys.mdx → press-keys.mdx} +5 -5
- package/docs/{v7/provision.mdx → provision.mdx} +9 -9
- package/docs/quickstart-cli.mdx +437 -0
- package/docs/quickstart-github.mdx +54 -0
- package/docs/quickstart-manual.mdx +135 -0
- package/docs/quickstart.mdx +22 -0
- package/docs/{v7/redraw.mdx → redraw.mdx} +7 -7
- package/docs/{v7/reusable-code.mdx → reusable-code.mdx} +3 -3
- package/docs/{v7/right-click.mdx → right-click.mdx} +7 -7
- package/docs/{v7/screenshot.mdx → screenshot.mdx} +9 -9
- package/docs/{v7/screenshots.mdx → screenshots.mdx} +3 -3
- package/docs/{v7/scroll.mdx → scroll.mdx} +13 -13
- package/docs/{v7/secrets.mdx → secrets.mdx} +4 -4
- package/docs/{v7/self-hosted.mdx → self-hosted.mdx} +7 -7
- package/docs/{v7/test-results-json.mdx → test-results-json.mdx} +4 -4
- package/docs/{v7/type.mdx → type.mdx} +7 -7
- package/docs/{v7/variables.mdx → variables.mdx} +2 -2
- package/docs/{v7/wait.mdx → wait.mdx} +5 -5
- package/docs/what-is-testdriver.mdx +54 -0
- package/lib/environments.json +1 -1
- package/lib/github-comment.mjs +2 -3
- package/package.json +1 -1
- package/scripts/generate-skills.js +1 -1
- package/docs/v7/client.mdx +0 -486
- package/docs/v7/quickstart.mdx +0 -451
- package/docs/v7/what-is-testdriver.mdx +0 -54
- /package/docs/{v7/_drafts → _drafts}/architecture.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/auto-cache-key.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/awesome-logs-quick-ref.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/cli-to-sdk-migration.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/assert.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/exec.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/focus-application.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/hover-image.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/hover-text.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/if.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/match-image.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/press-keys.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/remember.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/run.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/scroll-until-image.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/scroll-until-text.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/scroll.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/type.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/wait-for-image.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/wait-for-text.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/commands/wait.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/contributing.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/dashcam-title-feature.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/hooks.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/init-command.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/playwright.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/plugin-migration.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/presets.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/progressive-disclosure.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/provision.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/quick-start-test-recording.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/screenshot.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/sdk-awesome-logs.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/sdk-browser-rendering.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/sdk-migration.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/sdk-v7-complete.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/self-hosting.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/test-recording.mdx +0 -0
- /package/docs/{v7/_drafts → _drafts}/writing-tests.mdx +0 -0
- /package/docs/{v7/examples → examples}/ai.mdx +0 -0
- /package/docs/{v7/examples → examples}/assert.mdx +0 -0
- /package/docs/{v7/examples → examples}/captcha-api.mdx +0 -0
- /package/docs/{v7/examples → examples}/chrome-extension.mdx +0 -0
- /package/docs/{v7/examples → examples}/drag-and-drop.mdx +0 -0
- /package/docs/{v7/examples → examples}/element-not-found.mdx +0 -0
- /package/docs/{v7/examples → examples}/findall-coffee-icons.mdx +0 -0
- /package/docs/{v7/examples → examples}/formatted-logging.mdx +0 -0
- /package/docs/{v7/examples → examples}/hover-image.mdx +0 -0
- /package/docs/{v7/examples → examples}/hover-text-with-description.mdx +0 -0
- /package/docs/{v7/examples → examples}/hover-text.mdx +0 -0
- /package/docs/{v7/examples → examples}/installer.mdx +0 -0
- /package/docs/{v7/examples → examples}/launch-vscode-linux.mdx +0 -0
- /package/docs/{v7/examples → examples}/match-image.mdx +0 -0
- /package/docs/{v7/examples → examples}/parse.mdx +0 -0
- /package/docs/{v7/examples → examples}/press-keys.mdx +0 -0
- /package/docs/{v7/examples → examples}/scroll-keyboard.mdx +0 -0
- /package/docs/{v7/examples → examples}/scroll-until-text.mdx +0 -0
- /package/docs/{v7/examples → examples}/scroll.mdx +0 -0
- /package/docs/{v7/examples → examples}/type.mdx +0 -0
- /package/docs/{v7/mcp.mdx → mcp.mdx} +0 -0
package/docs/client.mdx
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Client & Connection"
|
|
3
|
+
sidebarTitle: "Client & Connection"
|
|
4
|
+
description: "Create the TestDriver client, authenticate, and connect to a sandbox"
|
|
5
|
+
icon: "plug"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## Constructor
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
const testdriver = new TestDriver(apiKey, options)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Parameters
|
|
19
|
+
|
|
20
|
+
<ParamField path="apiKey" type="string" required>
|
|
21
|
+
Your TestDriver API key from the [dashboard](https://console.testdriver.ai/settings)
|
|
22
|
+
</ParamField>
|
|
23
|
+
|
|
24
|
+
<ParamField path="options" type="object">
|
|
25
|
+
The configuration options for the client. See [SDK Options](/options) for the full list, with defaults and examples for each option.
|
|
26
|
+
</ParamField>
|
|
27
|
+
|
|
28
|
+
### Example
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import TestDriver from 'testdriverai';
|
|
32
|
+
|
|
33
|
+
// API key is automatically loaded from TD_API_KEY in .env
|
|
34
|
+
const testdriver = new TestDriver({
|
|
35
|
+
os: 'windows',
|
|
36
|
+
resolution: '1920x1080',
|
|
37
|
+
logging: true,
|
|
38
|
+
analytics: true
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// With AI config for stricter verification
|
|
42
|
+
const testdriver = new TestDriver({
|
|
43
|
+
ai: { temperature: 0, top: { p: 0.9, k: 40 } }
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Or pass API key explicitly
|
|
47
|
+
const testdriver = new TestDriver('your-api-key', {
|
|
48
|
+
os: 'windows'
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Authentication
|
|
53
|
+
|
|
54
|
+
### auth()
|
|
55
|
+
|
|
56
|
+
Authenticate with the TestDriver API.
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
await testdriver.auth()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Returns:** `Promise<string>` - Authentication token
|
|
63
|
+
|
|
64
|
+
**Example:**
|
|
65
|
+
```javascript
|
|
66
|
+
await testdriver.auth();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<Note>
|
|
70
|
+
You must call `auth()` before `connect()`. Most examples call both sequentially.
|
|
71
|
+
</Note>
|
|
72
|
+
|
|
73
|
+
## Connection Management
|
|
74
|
+
|
|
75
|
+
### connect()
|
|
76
|
+
|
|
77
|
+
Connect to a sandbox environment. This creates or reconnects to a virtual machine where your tests will run.
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
await testdriver.connect(options)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Parameters
|
|
84
|
+
|
|
85
|
+
<ParamField path="options" type="object">
|
|
86
|
+
Connection options
|
|
87
|
+
|
|
88
|
+
<Expandable title="properties">
|
|
89
|
+
<ParamField path="newSandbox" type="boolean" default="false">
|
|
90
|
+
Force creation of a new sandbox instead of reusing an existing one
|
|
91
|
+
</ParamField>
|
|
92
|
+
|
|
93
|
+
<ParamField path="sandboxId" type="string">
|
|
94
|
+
Existing sandbox ID to reconnect to
|
|
95
|
+
</ParamField>
|
|
96
|
+
|
|
97
|
+
<ParamField path="ip" type="string">
|
|
98
|
+
Direct IP address to connect to (for self-hosted sandboxes)
|
|
99
|
+
</ParamField>
|
|
100
|
+
|
|
101
|
+
<ParamField path="sandboxAmi" type="string">
|
|
102
|
+
AMI to use for the sandbox (AWS deployments)
|
|
103
|
+
</ParamField>
|
|
104
|
+
|
|
105
|
+
<ParamField path="sandboxInstance" type="string">
|
|
106
|
+
Instance type for the sandbox (AWS deployments)
|
|
107
|
+
</ParamField>
|
|
108
|
+
|
|
109
|
+
<ParamField path="preview" type="string" default="browser">
|
|
110
|
+
Preview mode for live test visualization:
|
|
111
|
+
- `"browser"` - Opens debugger in default browser (default)
|
|
112
|
+
- `"ide"` - Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
|
|
113
|
+
- `"none"` - Headless mode, no visual preview
|
|
114
|
+
</ParamField>
|
|
115
|
+
|
|
116
|
+
<ParamField path="headless" type="boolean" default="false">
|
|
117
|
+
**Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
|
|
118
|
+
</ParamField>
|
|
119
|
+
|
|
120
|
+
<ParamField path="keepAlive" type="number" default="60000">
|
|
121
|
+
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.
|
|
122
|
+
</ParamField>
|
|
123
|
+
</Expandable>
|
|
124
|
+
</ParamField>
|
|
125
|
+
|
|
126
|
+
**Returns:** `Promise<Object>` - Sandbox instance details including `instanceId`, `ip`, `vncPort`, etc.
|
|
127
|
+
|
|
128
|
+
#### Examples
|
|
129
|
+
|
|
130
|
+
**Basic connection:**
|
|
131
|
+
```javascript
|
|
132
|
+
await testdriver.connect();
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Reconnect to existing sandbox:**
|
|
136
|
+
```javascript
|
|
137
|
+
const instance = await testdriver.connect({
|
|
138
|
+
sandboxId: 'existing-sandbox-id-123'
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Self-hosted sandbox:**
|
|
143
|
+
```javascript
|
|
144
|
+
await testdriver.connect({
|
|
145
|
+
ip: '192.168.1.100'
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### disconnect()
|
|
150
|
+
|
|
151
|
+
Disconnect from the sandbox and clean up resources.
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
await testdriver.disconnect()
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Returns:** `Promise<void>`
|
|
158
|
+
|
|
159
|
+
**Example:**
|
|
160
|
+
```javascript
|
|
161
|
+
afterAll(async () => {
|
|
162
|
+
await testdriver.disconnect();
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Instance Information
|
|
167
|
+
|
|
168
|
+
### getInstance()
|
|
169
|
+
|
|
170
|
+
Get the current sandbox instance details.
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
const instance = testdriver.getInstance()
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Returns:** `Object | null` - Sandbox instance information
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
```javascript
|
|
180
|
+
const instance = testdriver.getInstance();
|
|
181
|
+
console.log('Instance ID:', instance.instanceId);
|
|
182
|
+
console.log('IP Address:', instance.ip);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### getSessionId()
|
|
186
|
+
|
|
187
|
+
Get the current session ID for tracking and debugging.
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
const sessionId = testdriver.getSessionId()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Returns:** `string | null` - Session ID
|
|
194
|
+
|
|
195
|
+
**Example:**
|
|
196
|
+
```javascript
|
|
197
|
+
const sessionId = testdriver.getSessionId();
|
|
198
|
+
console.log('Session:', sessionId);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Logging & Events
|
|
202
|
+
|
|
203
|
+
### setLogging()
|
|
204
|
+
|
|
205
|
+
Enable or disable console logging at runtime.
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
testdriver.setLogging(enabled)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Parameters:**
|
|
212
|
+
- `enabled` (boolean) - Whether to enable logging
|
|
213
|
+
|
|
214
|
+
**Example:**
|
|
215
|
+
```javascript
|
|
216
|
+
// Disable logging for cleanup operations
|
|
217
|
+
testdriver.setLogging(false);
|
|
218
|
+
await testdriver.disconnect();
|
|
219
|
+
testdriver.setLogging(true);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### getEmitter()
|
|
223
|
+
|
|
224
|
+
Get the event emitter for custom event handling.
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
const emitter = testdriver.getEmitter()
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Returns:** `EventEmitter2` - Event emitter instance
|
|
231
|
+
|
|
232
|
+
**Example:**
|
|
233
|
+
```javascript
|
|
234
|
+
const emitter = testdriver.getEmitter();
|
|
235
|
+
|
|
236
|
+
emitter.on('command:start', (data) => {
|
|
237
|
+
console.log('Command started:', data);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
emitter.on('command:success', (data) => {
|
|
241
|
+
console.log('Command succeeded:', data);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
emitter.on('command:error', (error) => {
|
|
245
|
+
console.error('Command failed:', error);
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Complete Example
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
import { beforeAll, afterAll, describe, it } from 'vitest';
|
|
253
|
+
import TestDriver from 'testdriverai';
|
|
254
|
+
|
|
255
|
+
describe('My Test Suite', () => {
|
|
256
|
+
let testdriver;
|
|
257
|
+
|
|
258
|
+
beforeAll(async () => {
|
|
259
|
+
// Initialize client - API key loaded automatically from .env
|
|
260
|
+
testdriver = new TestDriver({
|
|
261
|
+
os: 'windows',
|
|
262
|
+
resolution: '1366x768',
|
|
263
|
+
logging: true
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// Set up event listeners
|
|
267
|
+
const emitter = testdriver.getEmitter();
|
|
268
|
+
emitter.on('log:info', (msg) => console.log('[INFO]', msg));
|
|
269
|
+
|
|
270
|
+
// Authenticate and connect
|
|
271
|
+
await testdriver.auth();
|
|
272
|
+
const instance = await testdriver.connect();
|
|
273
|
+
|
|
274
|
+
console.log('Connected to sandbox:', instance.instanceId);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
afterAll(async () => {
|
|
278
|
+
await testdriver.disconnect();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('runs a test', async () => {
|
|
282
|
+
// Your test code here
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Best Practices
|
|
288
|
+
|
|
289
|
+
<AccordionGroup>
|
|
290
|
+
<Accordion title="Reuse sandboxes across tests">
|
|
291
|
+
Use `beforeAll`/`afterAll` to create one sandbox per test suite rather than per test. This significantly reduces execution time.
|
|
292
|
+
</Accordion>
|
|
293
|
+
|
|
294
|
+
<Accordion title="Handle connection errors gracefully">
|
|
295
|
+
Wrap `connect()` in a try-catch block to handle network issues or quota limits:
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
try {
|
|
299
|
+
await testdriver.connect();
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error('Failed to connect:', error.message);
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
</Accordion>
|
|
306
|
+
|
|
307
|
+
<Accordion title="Always disconnect">
|
|
308
|
+
Use `afterAll` or try-finally blocks to ensure `disconnect()` is called even if tests fail. This prevents orphaned sandboxes.
|
|
309
|
+
</Accordion>
|
|
310
|
+
|
|
311
|
+
<Accordion title="Use environment variables for API keys">
|
|
312
|
+
Never hardcode API keys. The SDK automatically loads `TD_API_KEY` from your `.env` file:
|
|
313
|
+
|
|
314
|
+
```bash .env
|
|
315
|
+
TD_API_KEY=your_api_key_here
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
```javascript
|
|
319
|
+
// API key is loaded automatically - no need to pass it!
|
|
320
|
+
const testdriver = new TestDriver();
|
|
321
|
+
```
|
|
322
|
+
</Accordion>
|
|
323
|
+
</AccordionGroup>
|
|
@@ -5,7 +5,7 @@ description: "Catch regressions automatically with CI, auto-healing, and GitHub
|
|
|
5
5
|
icon: "shield-check"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
Prevent regressions by letting TestDriver run and repair itself on every change. Once you've [explored](/
|
|
8
|
+
Prevent regressions by letting TestDriver run and repair itself on every change. Once you've [explored](/generating-tests), [taught it your app](/caching), [run it](/copilot/running-tests), [validated outcomes](/making-assertions), [adapted to your UI](/performing-actions), and learned to [debug with screenshots](/debugging-with-screenshots), the last step is closing the loop: wire TestDriver into your pull requests so regressions never reach production.
|
|
9
9
|
|
|
10
10
|
Your AI agent can run tests on every PR, investigate failures, and propose fixes — and you can drive all of it from GitHub itself, whether you're at your desk or on your phone.
|
|
11
11
|
|
|
@@ -407,7 +407,7 @@ It may struggle with:
|
|
|
407
407
|
- New features requiring new assertions
|
|
408
408
|
- Complex multi-step interactions
|
|
409
409
|
|
|
410
|
-
For significant changes, create new tests by going back to [Explore](/
|
|
410
|
+
For significant changes, create new tests by going back to [Explore](/generating-tests) and generating them with the TestDriver agent.
|
|
411
411
|
|
|
412
412
|
<Card title="View Your Runs" icon="chart-line" href="https://console.testdriver.ai">
|
|
413
413
|
Open the TestDriver console to monitor test runs, healing PRs, and CI results across your projects.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
2
|
+
title: "Running Tests"
|
|
3
|
+
sidebarTitle: "Running Tests"
|
|
4
4
|
description: "Set up your environment and run TestDriver tests locally and in CI"
|
|
5
5
|
icon: "play"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
Run the tests you've explored and learned, anywhere. TestDriver tests are plain [Vitest](https://vitest.dev) files, so they run the same way on your machine and in CI — across web, desktop, and extensions on real VMs. This page walks through getting set up, configuring **where** and **how** your tests run (the device and app under test, and the sandbox machine), and actually running them locally and in CI.
|
|
9
9
|
|
|
10
|
-
If you haven't written tests yet, start with [Explore](/
|
|
10
|
+
If you haven't written tests yet, start with [Explore](/generating-tests) to generate your first tests and [Learn](/caching) to make them fast and reliable.
|
|
11
11
|
|
|
12
12
|
## Setup
|
|
13
13
|
|
|
@@ -483,7 +483,7 @@ describe("My Test", () => {
|
|
|
483
483
|
|--------|------|---------|-------------|
|
|
484
484
|
| `os` | string | `"linux"` | Operating system |
|
|
485
485
|
| `resolution` | string | `"1366x768"` | Screen resolution (Enterprise only) |
|
|
486
|
-
| `e2bTemplateId` | string | — | Custom E2B template ID (see [Self-Hosted](/
|
|
486
|
+
| `e2bTemplateId` | string | — | Custom E2B template ID (see [Self-Hosted](/self-hosted)) |
|
|
487
487
|
| `keepAlive` | number | `60000` | Ms to keep VM alive after disconnect |
|
|
488
488
|
| `reconnect` | boolean | `false` | Reconnect to last used sandbox |
|
|
489
489
|
|
|
@@ -662,7 +662,7 @@ Provision scripts let you run arbitrary setup steps before your test starts —
|
|
|
662
662
|
<Card
|
|
663
663
|
title="exec() Reference"
|
|
664
664
|
icon="terminal"
|
|
665
|
-
href="/
|
|
665
|
+
href="/exec"
|
|
666
666
|
>
|
|
667
667
|
Full reference for running shell and PowerShell commands in the sandbox.
|
|
668
668
|
</Card>
|
|
@@ -764,7 +764,7 @@ With the **Self-Hosted Enterprise plan** you get access to our golden VM base im
|
|
|
764
764
|
<Card
|
|
765
765
|
title="Self-Hosted Enterprise"
|
|
766
766
|
icon="server"
|
|
767
|
-
href="/
|
|
767
|
+
href="/self-hosted"
|
|
768
768
|
>
|
|
769
769
|
Preload software, configure custom hardware, and run unlimited tests with a flat license fee. Our team assists with deployment and setup.
|
|
770
770
|
</Card>
|
|
@@ -996,7 +996,7 @@ This is faster for:
|
|
|
996
996
|
- Fixing typos
|
|
997
997
|
|
|
998
998
|
<Tip>
|
|
999
|
-
When a test fails because the UI shifted, let TestDriver fix it for you automatically. See [Prevent](/
|
|
999
|
+
When a test fails because the UI shifted, let TestDriver fix it for you automatically. See [Prevent](/copilot/auto-healing) for auto-healing, and [Debug](/debugging-with-screenshots) for inspecting screenshots when a run goes wrong.
|
|
1000
1000
|
</Tip>
|
|
1001
1001
|
|
|
1002
1002
|
## Next
|
|
@@ -1004,7 +1004,7 @@ This is faster for:
|
|
|
1004
1004
|
<Card
|
|
1005
1005
|
title="Validate"
|
|
1006
1006
|
icon="circle-check"
|
|
1007
|
-
href="/
|
|
1007
|
+
href="/making-assertions"
|
|
1008
1008
|
>
|
|
1009
1009
|
Now that your tests run anywhere, learn how to make strong assertions that catch real bugs.
|
|
1010
1010
|
</Card>
|
|
@@ -6,7 +6,7 @@ icon: "computer"
|
|
|
6
6
|
|
|
7
7
|
## TestDriver Options
|
|
8
8
|
|
|
9
|
-
Configure TestDriver behavior with options
|
|
9
|
+
Configure the TestDriver behavior with options that you give to the `TestDriver()` function:
|
|
10
10
|
|
|
11
11
|
```javascript
|
|
12
12
|
const testdriver = TestDriver(context, {
|
|
@@ -7,13 +7,13 @@ icon: "video"
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
Dashcam
|
|
10
|
+
Dashcam makes automatic video recordings. It also collects the logs for your tests. It captures screen recordings, application logs, and test details. You can review them later.
|
|
11
11
|
|
|
12
12
|
## Basic Usage
|
|
13
13
|
|
|
14
14
|
### With Presets
|
|
15
15
|
|
|
16
|
-
Most presets
|
|
16
|
+
Most presets include Dashcam automatically:
|
|
17
17
|
|
|
18
18
|
```javascript
|
|
19
19
|
import { test } from 'vitest';
|
|
@@ -34,7 +34,7 @@ test('my test', async (context) => {
|
|
|
34
34
|
|
|
35
35
|
### Manual Setup
|
|
36
36
|
|
|
37
|
-
For more control,
|
|
37
|
+
For more control, make a Dashcam instance directly:
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
40
|
import TestDriver from 'testdriverai';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
2
|
+
title: "Debugging Tests"
|
|
3
|
+
sidebarTitle: "Debugging Tests"
|
|
4
4
|
description: "Diagnose failing tests with screenshots, replays, and logs"
|
|
5
5
|
icon: "bug"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
When a test fails, debug it
|
|
10
|
+
When a test fails, debug it. Look at what happened. Do not guess. TestDriver captures screenshots, video replays, and logs while your test runs. Thus you can replay the moment of the failure. You do not need to look at a stack trace. TestDriver MCP gives commands to view and examine the screenshots that TestDriver saved during the test. This lets you debug quickly, develop tests, and compare, without a manual open of image files.
|
|
11
11
|
|
|
12
12
|
<Note>
|
|
13
|
-
**Automatic Screenshots (Default: Enabled)**: TestDriver
|
|
13
|
+
**Automatic Screenshots (Default: Enabled)**: TestDriver captures screenshots automatically before and after each command. The screenshot name has the line number and the action. Thus it is easy to see which line of code made each screenshot. For example: `001-click-before-L42-submit-button.png`
|
|
14
14
|
</Note>
|
|
15
15
|
|
|
16
16
|
## MCP Commands
|
|
@@ -26,15 +26,15 @@ list_local_screenshots()
|
|
|
26
26
|
**Filter Parameters:**
|
|
27
27
|
|
|
28
28
|
<ParamField path="directory" type="string" optional>
|
|
29
|
-
Filter screenshots by test file or subdirectory (
|
|
29
|
+
Filter the screenshots by test file or subdirectory (for example, "login.test", "mcp-screenshots"). If you do not give this, the tool lists all screenshots.
|
|
30
30
|
</ParamField>
|
|
31
31
|
|
|
32
32
|
<ParamField path="line" type="number" optional>
|
|
33
|
-
Filter by exact line number from test file (
|
|
33
|
+
Filter by the exact line number from the test file (for example, 42 matches L42 in the filename).
|
|
34
34
|
</ParamField>
|
|
35
35
|
|
|
36
36
|
<ParamField path="lineRange" type="object" optional>
|
|
37
|
-
Filter by line number range. Example: `{ start: 10, end: 20 }` matches screenshots from lines 10-20.
|
|
37
|
+
Filter by a line number range. Example: `{ start: 10, end: 20 }` matches screenshots from lines 10-20.
|
|
38
38
|
</ParamField>
|
|
39
39
|
|
|
40
40
|
<ParamField path="action" type="string" optional>
|
|
@@ -411,16 +411,16 @@ When tests fail or behave unexpectedly, replay what happened step by step:
|
|
|
411
411
|
|
|
412
412
|
## Where this fits in the Guide
|
|
413
413
|
|
|
414
|
-
Debugging is what you reach for when a [Run](/
|
|
414
|
+
Debugging is what you reach for when a [Run](/copilot/running-tests) goes sideways or a [Validate](/making-assertions) assertion fails — the screenshots show you precisely what the AI saw before it acted. Once you've diagnosed the failure, the next step is to stop it from recurring.
|
|
415
415
|
|
|
416
416
|
## Related
|
|
417
417
|
|
|
418
|
-
- [screenshot()](/
|
|
419
|
-
- [Dashcam](/
|
|
420
|
-
- [assert()](/
|
|
418
|
+
- [screenshot()](/screenshot) - Capture screenshots during test execution
|
|
419
|
+
- [Dashcam](/dashcam) - Record full test sessions with video and logs
|
|
420
|
+
- [assert()](/assert) - Make AI-powered assertions that benefit from screenshot context
|
|
421
421
|
|
|
422
422
|
## Next
|
|
423
423
|
|
|
424
|
-
<Card title="Prevent" icon="shield-check" href="/
|
|
424
|
+
<Card title="Prevent" icon="shield-check" href="/copilot/auto-healing">
|
|
425
425
|
You've seen what went wrong — now keep it from happening again. Let auto-healing repair flaky tests automatically before they fail your suite.
|
|
426
426
|
</Card>
|