@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.
Files changed (174) hide show
  1. package/ai/skills/testdriver-assert/SKILL.md +5 -5
  2. package/ai/skills/testdriver-caching/SKILL.md +2 -2
  3. package/ai/skills/testdriver-changelog/SKILL.md +186 -0
  4. package/ai/skills/testdriver-claude-mcp-plugin/SKILL.md +208 -0
  5. package/ai/skills/testdriver-click/SKILL.md +13 -13
  6. package/ai/skills/testdriver-client/SKILL.md +1 -1
  7. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +5 -5
  8. package/ai/skills/testdriver-double-click/SKILL.md +7 -7
  9. package/ai/skills/testdriver-enterprise/SKILL.md +1 -1
  10. package/ai/skills/testdriver-events/SKILL.md +1 -1
  11. package/ai/skills/testdriver-exec/SKILL.md +10 -10
  12. package/ai/skills/testdriver-extract/SKILL.md +6 -6
  13. package/ai/skills/testdriver-find/SKILL.md +61 -61
  14. package/ai/skills/testdriver-focus-application/SKILL.md +6 -6
  15. package/ai/skills/testdriver-generating-tests/SKILL.md +3 -3
  16. package/ai/skills/testdriver-hosted/SKILL.md +3 -3
  17. package/ai/skills/testdriver-hover/SKILL.md +6 -6
  18. package/ai/skills/testdriver-making-assertions/SKILL.md +2 -2
  19. package/ai/skills/testdriver-mouse-down/SKILL.md +9 -9
  20. package/ai/skills/testdriver-mouse-up/SKILL.md +9 -9
  21. package/ai/skills/testdriver-parse/SKILL.md +4 -4
  22. package/ai/skills/testdriver-performing-actions/SKILL.md +4 -4
  23. package/ai/skills/testdriver-press-keys/SKILL.md +5 -5
  24. package/ai/skills/testdriver-quickstart/SKILL.md +51 -54
  25. package/ai/skills/testdriver-redraw/SKILL.md +1 -1
  26. package/ai/skills/testdriver-right-click/SKILL.md +7 -7
  27. package/ai/skills/testdriver-screenshot/SKILL.md +9 -9
  28. package/ai/skills/testdriver-scroll/SKILL.md +13 -13
  29. package/ai/skills/testdriver-self-hosted/SKILL.md +1 -1
  30. package/ai/skills/testdriver-type/SKILL.md +7 -7
  31. package/ai/skills/testdriver-wait/SKILL.md +5 -5
  32. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +11 -11
  33. package/docs/{v7/_drafts → _drafts}/agents.mdx +1 -1
  34. package/docs/{v7/_drafts → _drafts}/best-practices.mdx +4 -4
  35. package/docs/{v7/_drafts → _drafts}/caching-selectors.mdx +3 -3
  36. package/docs/{v7/_drafts → _drafts}/configuration.mdx +4 -4
  37. package/docs/{v7/_drafts → _drafts}/debugging.mdx +4 -4
  38. package/docs/{v7/_drafts → _drafts}/error-handling.mdx +4 -4
  39. package/docs/{v7/_drafts → _drafts}/faq.mdx +7 -7
  40. package/docs/{v7/_drafts → _drafts}/installation.mdx +2 -2
  41. package/docs/{v7/_drafts → _drafts}/migration.mdx +4 -4
  42. package/docs/{v7/_drafts → _drafts}/observable.mdx +3 -3
  43. package/docs/{v7/_drafts → _drafts}/powerful.mdx +4 -4
  44. package/docs/{v7/_drafts → _drafts}/readme.mdx +11 -11
  45. package/docs/{v7/_drafts → _drafts}/reports.mdx +4 -4
  46. package/docs/{v7/_drafts → _drafts}/scalable.mdx +10 -10
  47. package/docs/{v7/_drafts → _drafts}/troubleshooting.mdx +4 -4
  48. package/docs/{v7/_drafts → _drafts}/vitest-plugin.mdx +2 -2
  49. package/docs/{v7/_drafts → _drafts}/vitest.mdx +9 -9
  50. package/docs/_scripts/generate-examples.js +9 -10
  51. package/docs/_scripts/generate-skills.js +4 -4
  52. package/docs/{v7/agent.mdx → agent.mdx} +17 -17
  53. package/docs/{v7/assert.mdx → assert.mdx} +5 -5
  54. package/docs/{v7/aws-setup.mdx → aws-setup.mdx} +6 -6
  55. package/docs/{v7/cache.mdx → cache.mdx} +9 -9
  56. package/docs/{v7/caching.mdx → caching.mdx} +13 -12
  57. package/docs/{v7/captcha.mdx → captcha.mdx} +7 -7
  58. package/docs/changelog.mdx +13 -13
  59. package/docs/{v7/ci-cd.mdx → ci-cd.mdx} +10 -10
  60. package/docs/{v7/click.mdx → click.mdx} +13 -13
  61. package/docs/client.mdx +323 -0
  62. package/docs/{v7/copilot → copilot}/auto-healing.mdx +2 -2
  63. package/docs/{v7/copilot → copilot}/running-tests.mdx +8 -8
  64. package/docs/{v7/customizing-devices.mdx → customizing-devices.mdx} +1 -1
  65. package/docs/{v7/dashcam.mdx → dashcam.mdx} +3 -3
  66. package/docs/{v7/debugging-with-screenshots.mdx → debugging-with-screenshots.mdx} +12 -12
  67. package/docs/docs.json +429 -288
  68. package/docs/{v7/double-click.mdx → double-click.mdx} +7 -7
  69. package/docs/{v7/elements.mdx → elements.mdx} +7 -7
  70. package/docs/{v7/enterprise.mdx → enterprise.mdx} +2 -2
  71. package/docs/{v7/errors.mdx → errors.mdx} +3 -3
  72. package/docs/{v7/events.mdx → events.mdx} +4 -4
  73. package/docs/{v7/exec.mdx → exec.mdx} +10 -10
  74. package/docs/{v7/extract.mdx → extract.mdx} +10 -10
  75. package/docs/{v7/find.mdx → find.mdx} +61 -61
  76. package/docs/{v7/focus-application.mdx → focus-application.mdx} +6 -6
  77. package/docs/{v7/generating-tests.mdx → generating-tests.mdx} +10 -10
  78. package/docs/guide/best-practices-polling.mdx +6 -1
  79. package/docs/{v7/hosted.mdx → hosted.mdx} +7 -7
  80. package/docs/{v7/hover.mdx → hover.mdx} +6 -6
  81. package/docs/interacting-with-your-app.mdx +198 -0
  82. package/docs/locating-elements.mdx +423 -0
  83. package/docs/{v7/making-assertions.mdx → making-assertions.mdx} +7 -7
  84. package/docs/{v7/mouse-down.mdx → mouse-down.mdx} +9 -9
  85. package/docs/{v7/mouse-up.mdx → mouse-up.mdx} +9 -9
  86. package/docs/options.mdx +320 -0
  87. package/docs/{v7/parse.mdx → parse.mdx} +12 -12
  88. package/docs/{v7/performing-actions.mdx → performing-actions.mdx} +11 -11
  89. package/docs/{v7/press-keys.mdx → press-keys.mdx} +5 -5
  90. package/docs/{v7/provision.mdx → provision.mdx} +9 -9
  91. package/docs/quickstart-cli.mdx +437 -0
  92. package/docs/quickstart-github.mdx +54 -0
  93. package/docs/quickstart-manual.mdx +135 -0
  94. package/docs/quickstart.mdx +22 -0
  95. package/docs/{v7/redraw.mdx → redraw.mdx} +7 -7
  96. package/docs/{v7/reusable-code.mdx → reusable-code.mdx} +3 -3
  97. package/docs/{v7/right-click.mdx → right-click.mdx} +7 -7
  98. package/docs/{v7/screenshot.mdx → screenshot.mdx} +9 -9
  99. package/docs/{v7/screenshots.mdx → screenshots.mdx} +3 -3
  100. package/docs/{v7/scroll.mdx → scroll.mdx} +13 -13
  101. package/docs/{v7/secrets.mdx → secrets.mdx} +4 -4
  102. package/docs/{v7/self-hosted.mdx → self-hosted.mdx} +7 -7
  103. package/docs/{v7/test-results-json.mdx → test-results-json.mdx} +4 -4
  104. package/docs/{v7/type.mdx → type.mdx} +7 -7
  105. package/docs/{v7/variables.mdx → variables.mdx} +2 -2
  106. package/docs/{v7/wait.mdx → wait.mdx} +5 -5
  107. package/docs/what-is-testdriver.mdx +54 -0
  108. package/lib/environments.json +1 -1
  109. package/lib/github-comment.mjs +2 -3
  110. package/package.json +1 -1
  111. package/scripts/generate-skills.js +1 -1
  112. package/docs/v7/client.mdx +0 -486
  113. package/docs/v7/quickstart.mdx +0 -451
  114. package/docs/v7/what-is-testdriver.mdx +0 -54
  115. /package/docs/{v7/_drafts → _drafts}/architecture.mdx +0 -0
  116. /package/docs/{v7/_drafts → _drafts}/auto-cache-key.mdx +0 -0
  117. /package/docs/{v7/_drafts → _drafts}/awesome-logs-quick-ref.mdx +0 -0
  118. /package/docs/{v7/_drafts → _drafts}/cli-to-sdk-migration.mdx +0 -0
  119. /package/docs/{v7/_drafts → _drafts}/commands/assert.mdx +0 -0
  120. /package/docs/{v7/_drafts → _drafts}/commands/exec.mdx +0 -0
  121. /package/docs/{v7/_drafts → _drafts}/commands/focus-application.mdx +0 -0
  122. /package/docs/{v7/_drafts → _drafts}/commands/hover-image.mdx +0 -0
  123. /package/docs/{v7/_drafts → _drafts}/commands/hover-text.mdx +0 -0
  124. /package/docs/{v7/_drafts → _drafts}/commands/if.mdx +0 -0
  125. /package/docs/{v7/_drafts → _drafts}/commands/match-image.mdx +0 -0
  126. /package/docs/{v7/_drafts → _drafts}/commands/press-keys.mdx +0 -0
  127. /package/docs/{v7/_drafts → _drafts}/commands/remember.mdx +0 -0
  128. /package/docs/{v7/_drafts → _drafts}/commands/run.mdx +0 -0
  129. /package/docs/{v7/_drafts → _drafts}/commands/scroll-until-image.mdx +0 -0
  130. /package/docs/{v7/_drafts → _drafts}/commands/scroll-until-text.mdx +0 -0
  131. /package/docs/{v7/_drafts → _drafts}/commands/scroll.mdx +0 -0
  132. /package/docs/{v7/_drafts → _drafts}/commands/type.mdx +0 -0
  133. /package/docs/{v7/_drafts → _drafts}/commands/wait-for-image.mdx +0 -0
  134. /package/docs/{v7/_drafts → _drafts}/commands/wait-for-text.mdx +0 -0
  135. /package/docs/{v7/_drafts → _drafts}/commands/wait.mdx +0 -0
  136. /package/docs/{v7/_drafts → _drafts}/contributing.mdx +0 -0
  137. /package/docs/{v7/_drafts → _drafts}/dashcam-title-feature.mdx +0 -0
  138. /package/docs/{v7/_drafts → _drafts}/hooks.mdx +0 -0
  139. /package/docs/{v7/_drafts → _drafts}/init-command.mdx +0 -0
  140. /package/docs/{v7/_drafts → _drafts}/playwright.mdx +0 -0
  141. /package/docs/{v7/_drafts → _drafts}/plugin-migration.mdx +0 -0
  142. /package/docs/{v7/_drafts → _drafts}/presets.mdx +0 -0
  143. /package/docs/{v7/_drafts → _drafts}/progressive-disclosure.mdx +0 -0
  144. /package/docs/{v7/_drafts → _drafts}/provision.mdx +0 -0
  145. /package/docs/{v7/_drafts → _drafts}/quick-start-test-recording.mdx +0 -0
  146. /package/docs/{v7/_drafts → _drafts}/screenshot.mdx +0 -0
  147. /package/docs/{v7/_drafts → _drafts}/sdk-awesome-logs.mdx +0 -0
  148. /package/docs/{v7/_drafts → _drafts}/sdk-browser-rendering.mdx +0 -0
  149. /package/docs/{v7/_drafts → _drafts}/sdk-migration.mdx +0 -0
  150. /package/docs/{v7/_drafts → _drafts}/sdk-v7-complete.mdx +0 -0
  151. /package/docs/{v7/_drafts → _drafts}/self-hosting.mdx +0 -0
  152. /package/docs/{v7/_drafts → _drafts}/test-recording.mdx +0 -0
  153. /package/docs/{v7/_drafts → _drafts}/writing-tests.mdx +0 -0
  154. /package/docs/{v7/examples → examples}/ai.mdx +0 -0
  155. /package/docs/{v7/examples → examples}/assert.mdx +0 -0
  156. /package/docs/{v7/examples → examples}/captcha-api.mdx +0 -0
  157. /package/docs/{v7/examples → examples}/chrome-extension.mdx +0 -0
  158. /package/docs/{v7/examples → examples}/drag-and-drop.mdx +0 -0
  159. /package/docs/{v7/examples → examples}/element-not-found.mdx +0 -0
  160. /package/docs/{v7/examples → examples}/findall-coffee-icons.mdx +0 -0
  161. /package/docs/{v7/examples → examples}/formatted-logging.mdx +0 -0
  162. /package/docs/{v7/examples → examples}/hover-image.mdx +0 -0
  163. /package/docs/{v7/examples → examples}/hover-text-with-description.mdx +0 -0
  164. /package/docs/{v7/examples → examples}/hover-text.mdx +0 -0
  165. /package/docs/{v7/examples → examples}/installer.mdx +0 -0
  166. /package/docs/{v7/examples → examples}/launch-vscode-linux.mdx +0 -0
  167. /package/docs/{v7/examples → examples}/match-image.mdx +0 -0
  168. /package/docs/{v7/examples → examples}/parse.mdx +0 -0
  169. /package/docs/{v7/examples → examples}/press-keys.mdx +0 -0
  170. /package/docs/{v7/examples → examples}/scroll-keyboard.mdx +0 -0
  171. /package/docs/{v7/examples → examples}/scroll-until-text.mdx +0 -0
  172. /package/docs/{v7/examples → examples}/scroll.mdx +0 -0
  173. /package/docs/{v7/examples → examples}/type.mdx +0 -0
  174. /package/docs/{v7/mcp.mdx → mcp.mdx} +0 -0
@@ -1,486 +0,0 @@
1
- ---
2
- title: "TestDriver Client"
3
- sidebarTitle: "Client"
4
- description: "Initialize and configure the TestDriver SDK client"
5
- icon: "plug"
6
- ---
7
-
8
- ## Overview
9
-
10
- The `TestDriver` client is the main entry point for the SDK. It handles authentication, sandbox connection, and provides access to all testing 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
- Configuration options for the client
26
-
27
- <Expandable title="properties">
28
- <ParamField path="os" type="string" default="linux">
29
- Operating system for the sandbox: `'windows'` or `'linux'`
30
- </ParamField>
31
-
32
- <ParamField path="resolution" type="string" default="1366x768">
33
- Screen resolution for the sandbox (e.g., `'1920x1080'`, `'1366x768'`). Custom resolutions are only available on Enterprise plans.
34
- </ParamField>
35
-
36
- <ParamField path="apiRoot" type="string">
37
- API endpoint URL (typically only changed for self-hosted deployments)
38
- </ParamField>
39
-
40
- <ParamField path="analytics" type="boolean" default="true">
41
- Enable or disable usage analytics
42
- </ParamField>
43
-
44
- <ParamField path="logging" type="boolean" default="true">
45
- Enable or disable console logging
46
- </ParamField>
47
-
48
- <ParamField path="autoScreenshots" type="boolean" default="false">
49
- Automatically capture screenshots before and after each command. Screenshots are saved to `.testdriver/screenshots/<test>/` with descriptive filenames that include the line number and action name. Format: `<seq>-<action>-<phase>-L<line>-<description>.png`
50
- </ParamField>
51
-
52
- <ParamField path="newSandbox" type="boolean" default="true">
53
- Force creation of a new sandbox instead of reusing an existing one
54
- </ParamField>
55
-
56
- <ParamField path="reconnect" type="boolean" default="false">
57
- Reattach to the last used sandbox instead of creating a new one. When `true`, the SDK reads the sandbox id from `.testdriver/last-sandbox` (written automatically on every successful connect) and rejoins that VM. Provision methods (`chrome`, `vscode`, `installer`, etc.) are skipped because the application is already running. The previous sandbox must still be alive — see [`keepAlive`](#keepalive) and the [Run guide](/v7/copilot/running-tests#keeping-machines-alive-between-runs).
58
- </ParamField>
59
-
60
- <ParamField path="sandboxId" type="string">
61
- Reattach to a specific sandbox id instead of the one recorded in `.testdriver/last-sandbox`. Use this for CI matrices or to pin a chain of tests to a known VM. Implies `reconnect: true` behavior (provision calls are skipped).
62
- </ParamField>
63
-
64
- <ParamField path="preview" type="string" default="browser">
65
- Preview mode for live test visualization:
66
- - `"browser"` — Opens debugger in default browser (default)
67
- - `"ide"` — Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
68
- - `"none"` — Headless mode, no visual preview
69
- </ParamField>
70
-
71
- <ParamField path="headless" type="boolean" default="false">
72
- **Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
73
- </ParamField>
74
-
75
- <ParamField path="debugOnFailure" type="boolean" default="false">
76
- Keep the sandbox alive when a test fails so you can reconnect and debug interactively. The sandbox ID is printed to the console.
77
- </ParamField>
78
-
79
- <ParamField path="ip" type="string">
80
- Direct IP address to connect to a running sandbox instance (for self-hosted deployments)
81
- </ParamField>
82
-
83
- <ParamField path="sandboxAmi" type="string">
84
- Custom AMI ID for the sandbox instance (AWS deployments, e.g., `'ami-1234'`)
85
- </ParamField>
86
-
87
- <ParamField path="sandboxInstance" type="string">
88
- EC2 instance type for the sandbox (AWS deployments, e.g., `'i3.metal'`)
89
- </ParamField>
90
-
91
- <ParamField path="cache" type="boolean | object" default="true">
92
- Enable or disable element caching, or provide advanced threshold configuration.
93
-
94
- <Expandable title="advanced config">
95
- <ParamField path="enabled" type="boolean" default="true">
96
- Enable or disable caching
97
- </ParamField>
98
-
99
- <ParamField path="thresholds" type="object">
100
- Fine-tune cache matching
101
-
102
- <Expandable title="properties">
103
- <ParamField path="find" type="object">
104
- Thresholds for `find()` operations
105
-
106
- <Expandable title="properties">
107
- <ParamField path="screen" type="number" default="0.05">
108
- Pixel diff threshold for screen comparison (0-1). `0.05` = 5% diff allowed.
109
- </ParamField>
110
-
111
- <ParamField path="element" type="number" default="0.8">
112
- OpenCV template match threshold for element matching (0-1). `0.8` = 80% correlation.
113
- </ParamField>
114
- </Expandable>
115
- </ParamField>
116
-
117
- <ParamField path="assert" type="number" default="0.05">
118
- Pixel diff threshold for `assert()` operations (0-1). `0.05` = 5% diff allowed.
119
- </ParamField>
120
- </Expandable>
121
- </ParamField>
122
- </Expandable>
123
- </ParamField>
124
-
125
- <ParamField path="cacheKey" type="string">
126
- Cache key for element finding operations. If provided, enables caching tied to this key.
127
- </ParamField>
128
-
129
- <ParamField path="verify" type="boolean" default="false">
130
- Global default for AI verification of located elements. When `true`, every `find()` runs a second AI check to confirm the returned coordinates actually match the requested element (catching hallucinated or incorrect positions), at the cost of extra latency. Can be overridden per call via `find(description, { verify: true | false })`.
131
- </ParamField>
132
-
133
- <ParamField path="dashcam" type="boolean" default="true">
134
- Enable or disable Dashcam video recording
135
- </ParamField>
136
-
137
- <ParamField path="redraw" type="boolean | object" default="true">
138
- Enable or disable screen-change (redraw) detection, or provide advanced configuration.
139
-
140
- <Expandable title="advanced config">
141
- <ParamField path="enabled" type="boolean" default="true">
142
- Enable or disable redraw detection
143
- </ParamField>
144
-
145
- <ParamField path="thresholds" type="object">
146
- Threshold configuration
147
-
148
- <Expandable title="properties">
149
- <ParamField path="screen" type="number | false" default="0.05">
150
- Pixel diff threshold (0-1). Set to `false` to disable screen redraw detection.
151
- </ParamField>
152
-
153
- <ParamField path="network" type="boolean" default="false">
154
- Enable or disable network activity monitoring
155
- </ParamField>
156
- </Expandable>
157
- </ParamField>
158
- </Expandable>
159
- </ParamField>
160
-
161
- <ParamField path="environment" type="object">
162
- Additional environment variables to pass to the sandbox
163
- </ParamField>
164
-
165
- <ParamField path="ai" type="object">
166
- Global AI sampling configuration. Controls how the AI model generates responses for `find()` verification and `assert()` calls. Can be overridden per call.
167
-
168
- <Expandable title="properties">
169
- <ParamField path="temperature" type="number">
170
- Controls randomness in AI responses. `0` = deterministic (best for verification), higher values = more creative. Default: `0` for find verification, model default for assert.
171
- </ParamField>
172
-
173
- <ParamField path="top" type="object">
174
- Nucleus and top-k sampling parameters
175
-
176
- <Expandable title="properties">
177
- <ParamField path="p" type="number">
178
- Top-P (nucleus sampling). Limits token choices to the smallest set whose cumulative probability exceeds P. Lower values = more focused responses. Range: 0-1.
179
- </ParamField>
180
-
181
- <ParamField path="k" type="number">
182
- Top-K sampling. Limits token choices to the top K most likely tokens. `1` = always pick the most likely token. `0` = disabled (consider all tokens).
183
- </ParamField>
184
- </Expandable>
185
- </ParamField>
186
- </Expandable>
187
- </ParamField>
188
- </Expandable>
189
- </ParamField>
190
-
191
- ### Example
192
-
193
- ```javascript
194
- import TestDriver from 'testdriverai';
195
-
196
- // API key is automatically loaded from TD_API_KEY in .env
197
- const testdriver = new TestDriver({
198
- os: 'windows',
199
- resolution: '1920x1080',
200
- logging: true,
201
- analytics: true
202
- });
203
-
204
- // With AI config for stricter verification
205
- const testdriver = new TestDriver({
206
- ai: { temperature: 0, top: { p: 0.9, k: 40 } }
207
- });
208
-
209
- // Or pass API key explicitly
210
- const testdriver = new TestDriver('your-api-key', {
211
- os: 'windows'
212
- });
213
- ```
214
-
215
- ## Authentication
216
-
217
- ### auth()
218
-
219
- Authenticate with the TestDriver API.
220
-
221
- ```javascript
222
- await testdriver.auth()
223
- ```
224
-
225
- **Returns:** `Promise<string>` - Authentication token
226
-
227
- **Example:**
228
- ```javascript
229
- await testdriver.auth();
230
- ```
231
-
232
- <Note>
233
- You must call `auth()` before `connect()`. Most examples call both sequentially.
234
- </Note>
235
-
236
- ## Connection Management
237
-
238
- ### connect()
239
-
240
- Connect to a sandbox environment. This creates or reconnects to a virtual machine where your tests will run.
241
-
242
- ```javascript
243
- await testdriver.connect(options)
244
- ```
245
-
246
- #### Parameters
247
-
248
- <ParamField path="options" type="object">
249
- Connection options
250
-
251
- <Expandable title="properties">
252
- <ParamField path="newSandbox" type="boolean" default="false">
253
- Force creation of a new sandbox instead of reusing an existing one
254
- </ParamField>
255
-
256
- <ParamField path="sandboxId" type="string">
257
- Existing sandbox ID to reconnect to
258
- </ParamField>
259
-
260
- <ParamField path="ip" type="string">
261
- Direct IP address to connect to (for self-hosted sandboxes)
262
- </ParamField>
263
-
264
- <ParamField path="sandboxAmi" type="string">
265
- AMI to use for the sandbox (AWS deployments)
266
- </ParamField>
267
-
268
- <ParamField path="sandboxInstance" type="string">
269
- Instance type for the sandbox (AWS deployments)
270
- </ParamField>
271
-
272
- <ParamField path="preview" type="string" default="browser">
273
- Preview mode for live test visualization:
274
- - `"browser"` - Opens debugger in default browser (default)
275
- - `"ide"` - Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
276
- - `"none"` - Headless mode, no visual preview
277
- </ParamField>
278
-
279
- <ParamField path="headless" type="boolean" default="false">
280
- **Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
281
- </ParamField>
282
-
283
- <ParamField path="keepAlive" type="number" default="60000">
284
- 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.
285
- </ParamField>
286
- </Expandable>
287
- </ParamField>
288
-
289
- **Returns:** `Promise&lt;Object&gt;` - Sandbox instance details including `instanceId`, `ip`, `vncPort`, etc.
290
-
291
- #### Examples
292
-
293
- **Basic connection:**
294
- ```javascript
295
- await testdriver.connect();
296
- ```
297
-
298
- **Reconnect to existing sandbox:**
299
- ```javascript
300
- const instance = await testdriver.connect({
301
- sandboxId: 'existing-sandbox-id-123'
302
- });
303
- ```
304
-
305
- **Self-hosted sandbox:**
306
- ```javascript
307
- await testdriver.connect({
308
- ip: '192.168.1.100'
309
- });
310
- ```
311
-
312
- ### disconnect()
313
-
314
- Disconnect from the sandbox and clean up resources.
315
-
316
- ```javascript
317
- await testdriver.disconnect()
318
- ```
319
-
320
- **Returns:** `Promise<void>`
321
-
322
- **Example:**
323
- ```javascript
324
- afterAll(async () => {
325
- await testdriver.disconnect();
326
- });
327
- ```
328
-
329
- ## Instance Information
330
-
331
- ### getInstance()
332
-
333
- Get the current sandbox instance details.
334
-
335
- ```javascript
336
- const instance = testdriver.getInstance()
337
- ```
338
-
339
- **Returns:** `Object | null` - Sandbox instance information
340
-
341
- **Example:**
342
- ```javascript
343
- const instance = testdriver.getInstance();
344
- console.log('Instance ID:', instance.instanceId);
345
- console.log('IP Address:', instance.ip);
346
- ```
347
-
348
- ### getSessionId()
349
-
350
- Get the current session ID for tracking and debugging.
351
-
352
- ```javascript
353
- const sessionId = testdriver.getSessionId()
354
- ```
355
-
356
- **Returns:** `string | null` - Session ID
357
-
358
- **Example:**
359
- ```javascript
360
- const sessionId = testdriver.getSessionId();
361
- console.log('Session:', sessionId);
362
- ```
363
-
364
- ## Logging & Events
365
-
366
- ### setLogging()
367
-
368
- Enable or disable console logging at runtime.
369
-
370
- ```javascript
371
- testdriver.setLogging(enabled)
372
- ```
373
-
374
- **Parameters:**
375
- - `enabled` (boolean) - Whether to enable logging
376
-
377
- **Example:**
378
- ```javascript
379
- // Disable logging for cleanup operations
380
- testdriver.setLogging(false);
381
- await testdriver.disconnect();
382
- testdriver.setLogging(true);
383
- ```
384
-
385
- ### getEmitter()
386
-
387
- Get the event emitter for custom event handling.
388
-
389
- ```javascript
390
- const emitter = testdriver.getEmitter()
391
- ```
392
-
393
- **Returns:** `EventEmitter2` - Event emitter instance
394
-
395
- **Example:**
396
- ```javascript
397
- const emitter = testdriver.getEmitter();
398
-
399
- emitter.on('command:start', (data) => {
400
- console.log('Command started:', data);
401
- });
402
-
403
- emitter.on('command:success', (data) => {
404
- console.log('Command succeeded:', data);
405
- });
406
-
407
- emitter.on('command:error', (error) => {
408
- console.error('Command failed:', error);
409
- });
410
- ```
411
-
412
- ## Complete Example
413
-
414
- ```javascript
415
- import { beforeAll, afterAll, describe, it } from 'vitest';
416
- import TestDriver from 'testdriverai';
417
-
418
- describe('My Test Suite', () => {
419
- let testdriver;
420
-
421
- beforeAll(async () => {
422
- // Initialize client - API key loaded automatically from .env
423
- testdriver = new TestDriver({
424
- os: 'windows',
425
- resolution: '1366x768',
426
- logging: true
427
- });
428
-
429
- // Set up event listeners
430
- const emitter = testdriver.getEmitter();
431
- emitter.on('log:info', (msg) => console.log('[INFO]', msg));
432
-
433
- // Authenticate and connect
434
- await testdriver.auth();
435
- const instance = await testdriver.connect();
436
-
437
- console.log('Connected to sandbox:', instance.instanceId);
438
- });
439
-
440
- afterAll(async () => {
441
- await testdriver.disconnect();
442
- });
443
-
444
- it('runs a test', async () => {
445
- // Your test code here
446
- });
447
- });
448
- ```
449
-
450
- ## Best Practices
451
-
452
- <AccordionGroup>
453
- <Accordion title="Reuse sandboxes across tests">
454
- Use `beforeAll`/`afterAll` to create one sandbox per test suite rather than per test. This significantly reduces execution time.
455
- </Accordion>
456
-
457
- <Accordion title="Handle connection errors gracefully">
458
- Wrap `connect()` in a try-catch block to handle network issues or quota limits:
459
-
460
- ```javascript
461
- try {
462
- await testdriver.connect();
463
- } catch (error) {
464
- console.error('Failed to connect:', error.message);
465
- throw error;
466
- }
467
- ```
468
- </Accordion>
469
-
470
- <Accordion title="Always disconnect">
471
- Use `afterAll` or try-finally blocks to ensure `disconnect()` is called even if tests fail. This prevents orphaned sandboxes.
472
- </Accordion>
473
-
474
- <Accordion title="Use environment variables for API keys">
475
- Never hardcode API keys. The SDK automatically loads `TD_API_KEY` from your `.env` file:
476
-
477
- ```bash .env
478
- TD_API_KEY=your_api_key_here
479
- ```
480
-
481
- ```javascript
482
- // API key is loaded automatically - no need to pass it!
483
- const testdriver = new TestDriver();
484
- ```
485
- </Accordion>
486
- </AccordionGroup>