testdriverai 7.1.4 → 7.2.2

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 (72) hide show
  1. package/.github/workflows/acceptance.yaml +81 -0
  2. package/.github/workflows/publish.yaml +44 -0
  3. package/agent/index.js +18 -19
  4. package/agent/interface.js +4 -0
  5. package/agent/lib/commands.js +321 -121
  6. package/agent/lib/redraw.js +99 -39
  7. package/agent/lib/sandbox.js +98 -6
  8. package/agent/lib/sdk.js +25 -0
  9. package/agent/lib/system.js +2 -1
  10. package/agent/lib/validation.js +6 -6
  11. package/docs/docs.json +211 -101
  12. package/docs/snippets/tests/type-repeated-replay.mdx +1 -1
  13. package/docs/v7/_drafts/caching-selectors.mdx +24 -0
  14. package/docs/v7/api/act.mdx +1 -1
  15. package/docs/v7/api/assert.mdx +1 -1
  16. package/docs/v7/api/assertions.mdx +7 -7
  17. package/docs/v7/api/elements.mdx +78 -0
  18. package/docs/v7/api/find.mdx +38 -0
  19. package/docs/v7/api/focusApplication.mdx +2 -2
  20. package/docs/v7/api/hover.mdx +2 -2
  21. package/docs/v7/features/ai-native.mdx +57 -71
  22. package/docs/v7/features/application-logs.mdx +353 -0
  23. package/docs/v7/features/browser-logs.mdx +414 -0
  24. package/docs/v7/features/cache-management.mdx +402 -0
  25. package/docs/v7/features/continuous-testing.mdx +346 -0
  26. package/docs/v7/features/coverage.mdx +508 -0
  27. package/docs/v7/features/data-driven-testing.mdx +441 -0
  28. package/docs/v7/features/easy-to-write.mdx +2 -73
  29. package/docs/v7/features/enterprise.mdx +155 -39
  30. package/docs/v7/features/fast.mdx +63 -81
  31. package/docs/v7/features/managed-sandboxes.mdx +384 -0
  32. package/docs/v7/features/network-monitoring.mdx +568 -0
  33. package/docs/v7/features/observable.mdx +3 -22
  34. package/docs/v7/features/parallel-execution.mdx +381 -0
  35. package/docs/v7/features/powerful.mdx +1 -1
  36. package/docs/v7/features/reports.mdx +414 -0
  37. package/docs/v7/features/sandbox-customization.mdx +229 -0
  38. package/docs/v7/features/scalable.mdx +217 -2
  39. package/docs/v7/features/stable.mdx +106 -147
  40. package/docs/v7/features/system-performance.mdx +616 -0
  41. package/docs/v7/features/test-analytics.mdx +373 -0
  42. package/docs/v7/features/test-cases.mdx +393 -0
  43. package/docs/v7/features/test-replays.mdx +408 -0
  44. package/docs/v7/features/test-reports.mdx +308 -0
  45. package/docs/v7/getting-started/{running-and-debugging.mdx → debugging-tests.mdx} +12 -142
  46. package/docs/v7/getting-started/quickstart.mdx +22 -305
  47. package/docs/v7/getting-started/running-tests.mdx +173 -0
  48. package/docs/v7/overview/what-is-testdriver.mdx +2 -14
  49. package/docs/v7/presets/chrome-extension.mdx +147 -122
  50. package/interfaces/cli/commands/init.js +3 -3
  51. package/interfaces/cli/lib/base.js +3 -2
  52. package/interfaces/logger.js +0 -2
  53. package/interfaces/shared-test-state.mjs +0 -5
  54. package/interfaces/vitest-plugin.mjs +70 -50
  55. package/lib/core/Dashcam.js +60 -85
  56. package/lib/vitest/hooks.mjs +42 -50
  57. package/package.json +1 -1
  58. package/sdk-log-formatter.js +350 -175
  59. package/sdk.d.ts +36 -3
  60. package/sdk.js +431 -116
  61. package/setup/aws/cloudformation.yaml +2 -2
  62. package/setup/aws/self-hosted.yml +1 -1
  63. package/test/testdriver/chrome-extension.test.mjs +55 -72
  64. package/test/testdriver/element-not-found.test.mjs +2 -1
  65. package/test/testdriver/hover-image.test.mjs +1 -1
  66. package/test/testdriver/scroll-until-text.test.mjs +10 -6
  67. package/test/testdriver/setup/lifecycleHelpers.mjs +19 -24
  68. package/test/testdriver/setup/testHelpers.mjs +18 -23
  69. package/vitest.config.mjs +3 -3
  70. package/.github/workflows/linux-tests.yml +0 -28
  71. package/docs/v7/getting-started/generating-tests.mdx +0 -525
  72. package/test/testdriver/auto-cache-key-demo.test.mjs +0 -56
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "AI-Native"
2
+ title: "AI Test Generation"
3
3
  description: "Built specifically for AI agents and autonomous testing"
4
4
  icon: "robot"
5
5
  ---
@@ -74,48 +74,65 @@ AI-powered element location, assertions, and instructions:
74
74
  </Tab>
75
75
  </Tabs>
76
76
 
77
- ## Iterative Selector Refinement
77
+ ## Test Generation with Claude Code
78
78
 
79
- AI agents can iteratively refine selectors when initial attempts fail:
79
+ Feed natural language requirements directly to Claude Code to generate complete test suites:
80
80
 
81
- ```javascript
82
- test('iterative debugging', async (context) => {
83
- const testdriver = new TestDriver({
84
- apiKey: process.env.TD_API_KEY
85
- });
81
+ <Steps>
86
82
 
87
- const instance = await testdriver.connect();
88
- const sandboxId = instance.instanceId;
89
-
90
- // Try multiple selector variations
91
- const selectors = [
92
- 'submit button',
93
- 'blue submit button',
94
- 'submit button in bottom right',
95
- 'button with "Submit" text',
96
- 'primary action button'
97
- ];
98
-
99
- for (const selector of selectors) {
100
- try {
101
- console.log(`Trying: ${selector}`);
102
- const element = await testdriver.find(selector);
103
- console.log(`✓ Found with: ${selector}`);
104
- await element.click();
105
- break; // Success!
106
- } catch (error) {
107
- console.log(`✗ Failed with: ${selector}`);
108
- console.log(` Similarity: ${error.similarity}`);
109
- console.log(` Confidence: ${error.confidence}`);
110
- }
111
- }
83
+ <Step title="Ask Claude Code to Generate Tests">
84
+ Provide the requirements to Claude Code with context about your testing setup:
112
85
 
113
- await testdriver.disconnect();
114
- });
115
- ```
86
+ ```text
87
+ Generate a TestDriver test using Vitest for these requirements:
88
+
89
+ Test the login flow:
90
+ 1. Navigate to login page
91
+ 2. Enter valid credentials
92
+ 3. Click submit
93
+ 4. Verify dashboard appears
94
+
95
+ Use the chrome preset and target https://myapp.com/login
96
+ ```
97
+ </Step>
98
+
99
+ <Step title="Claude Generates Complete Tests">
100
+ Claude Code will create production-ready test files:
101
+
102
+ ```javascript
103
+ import { test } from 'vitest';
104
+ import { chrome } from 'testdriverai/presets';
105
+
106
+ test('user can login', async (context) => {
107
+ const { testdriver } = await chrome(context, {
108
+ url: 'https://myapp.com/login'
109
+ });
110
+
111
+ await testdriver.find('email input').type('user@example.com');
112
+ await testdriver.find('password input').type('password', { secret: true });
113
+ await testdriver.find('Login button').click();
114
+
115
+ await testdriver.assert('Dashboard is visible');
116
+ });
117
+ ```
118
+ </Step>
119
+
120
+ <Step title="Run Tests and Iterate">
121
+ Ask Claude Code to run the tests and refine based on results:
122
+
123
+ ```text
124
+ Run these tests and fix any failures. Then add tests for:
125
+ - Invalid credentials
126
+ - Empty form submission
127
+ - Password visibility toggle
128
+ ```
129
+
130
+ Claude will execute the tests, analyze failures, and automatically refine the test code.
131
+ </Step>
132
+ </Steps>
116
133
 
117
134
  <Tip>
118
- AI agents can analyze error similarity scores to refine subsequent selector attempts intelligently.
135
+ Claude Code understands TestDriver's natural language API and will automatically use appropriate selectors, assertions, and best practices like `secret: true` for passwords.
119
136
  </Tip>
120
137
 
121
138
  ## Sandbox Reconnection
@@ -147,12 +164,9 @@ test('reconnect attempt', async () => {
147
164
  apiKey: process.env.TD_API_KEY
148
165
  });
149
166
 
150
- // Read last sandbox ID
151
- const lastSandboxId = testdriver.getLastSandboxId();
152
-
153
- // Reconnect
167
+ // Manually specify the sandbox ID from previous test
154
168
  await testdriver.connect({
155
- sandboxId: lastSandboxId,
169
+ sandboxId: 'your-sandbox-id-here',
156
170
  newSandbox: false
157
171
  });
158
172
 
@@ -164,7 +178,7 @@ test('reconnect attempt', async () => {
164
178
  ```
165
179
 
166
180
  <Card title="Automatic Sandbox Tracking" icon="bookmark">
167
- TestDriver saves the last sandbox ID to `.testdriver/last-sandbox` automatically. AI agents can read this file to reconnect without manual ID tracking.
181
+ TestDriver automatically saves the last sandbox ID to `~/.testdriverai-last-sandbox`. By default, `newSandbox: true`, so each connection creates a new sandbox. Set `newSandbox: false` and provide a `sandboxId` to reconnect to an existing sandbox.
168
182
  </Card>
169
183
 
170
184
  ## Error Analysis
@@ -195,34 +209,6 @@ try {
195
209
  }
196
210
  ```
197
211
 
198
- ## Autonomous Test Generation
199
-
200
- AI agents can generate entire test suites:
201
-
202
- ```javascript
203
- // AI agent generates tests from requirements
204
- const requirements = `
205
- Test the login flow:
206
- 1. Navigate to login page
207
- 2. Enter valid credentials
208
- 3. Click submit
209
- 4. Verify dashboard appears
210
- `;
211
-
212
- // Agent generates:
213
- test('user can login', async (context) => {
214
- const { testdriver } = await chrome(context, {
215
- url: 'https://myapp.com/login'
216
- });
217
-
218
- await testdriver.find('email input').type('user@example.com');
219
- await testdriver.find('password input').type('password', { secret: true });
220
- await testdriver.find('Login button').click();
221
-
222
- await testdriver.assert('Dashboard is visible');
223
- });
224
- ```
225
-
226
212
  ## MCP Integration (Coming Soon)
227
213
 
228
214
  Query test infrastructure using natural language:
@@ -0,0 +1,353 @@
1
+ ---
2
+ title: "Application Logs"
3
+ description: "TestDriver SDK logs and test execution output"
4
+ icon: "terminal"
5
+ ---
6
+
7
+ View detailed TestDriver application logs including test execution steps, AI vision analysis results, cache hits/misses, and debugging information.
8
+
9
+ ## Application Log Output
10
+
11
+ TestDriver logs every action and decision during test execution:
12
+
13
+ ```
14
+ Test Execution Logs:
15
+ ┌────────────────────────────────────────────────────┐
16
+ │ [0:00] ℹ️ System info configured │
17
+ │ [0:00] ℹ️ Response cache: /Users/.../cache.json │
18
+ │ [0:05] ✓ Connected to sandbox i-0abc123def │
19
+ │ [0:08] ℹ️ Browser launched: Chrome 120.0 │
20
+ │ [0:12] ✓ Navigated to https://example.com │
21
+ │ [0:15] 🔍 Finding: "login button" │
22
+ │ [0:18] ✓ Cache hit: login button (fe68cfe...) │
23
+ │ [0:18] ✓ Element found at (512, 387) │
24
+ │ [0:19] ✓ Clicked login button │
25
+ │ [0:22] 🔍 Finding: "email input" │
26
+ │ [0:25] ⚡ Cache miss: analyzing with AI vision │
27
+ │ [0:28] ✓ Element found at (450, 290) │
28
+ │ [0:28] ℹ️ Cached for future runs │
29
+ │ [0:29] ✓ Typed "user@example.com" │
30
+ │ [0:32] ✓ Response was successful! │
31
+ │ [0:35] ✓ Test completed: PASSED │
32
+ └────────────────────────────────────────────────────┘
33
+ ```
34
+
35
+ ## Log Levels
36
+
37
+ TestDriver uses standard log levels:
38
+
39
+ <CardGroup cols={2}>
40
+ <Card title="INFO" icon="circle-info" color="blue">
41
+ General information about test execution
42
+ - Configuration loaded
43
+ - Sandbox connection
44
+ - Navigation events
45
+ - Cache operations
46
+ </Card>
47
+
48
+ <Card title="SUCCESS" icon="check" color="green">
49
+ Successful operations
50
+ - Element found
51
+ - Action completed
52
+ - Assertion passed
53
+ - Test passed
54
+ </Card>
55
+
56
+ <Card title="WARNING" icon="triangle-exclamation" color="yellow">
57
+ Non-critical issues
58
+ - Slow operations
59
+ - Retry attempts
60
+ - Deprecated API usage
61
+ - Cache near limit
62
+ </Card>
63
+
64
+ <Card title="ERROR" icon="circle-xmark" color="red">
65
+ Failures and exceptions
66
+ - Element not found
67
+ - Timeout errors
68
+ - Assertion failures
69
+ - Test failures
70
+ </Card>
71
+
72
+ <Card title="DEBUG" icon="bug" color="gray">
73
+ Detailed debugging information
74
+ - AI vision analysis details
75
+ - Screenshot hashes
76
+ - Cache key generation
77
+ - Internal SDK operations
78
+ </Card>
79
+ </CardGroup>
80
+
81
+ ## AI Vision Analysis Logs
82
+
83
+ See how TestDriver finds elements:
84
+
85
+ ```
86
+ AI Vision Analysis:
87
+ ┌────────────────────────────────────────────────────┐
88
+ │ [0:22] 🔍 Finding: "submit button in login form" │
89
+ │ [0:23] ℹ️ Taking screenshot... │
90
+ │ [0:24] ℹ️ Screenshot hash: a8f3c21b4e9d7f... │
91
+ │ [0:24] ℹ️ Cache lookup: MISS │
92
+ │ [0:25] ℹ️ Sending to AI vision model... │
93
+ │ [0:26] ℹ️ AI analysis in progress... │
94
+ │ [0:28] ✓ Element identified with 98.5% confidence │
95
+ │ [0:28] ✓ Bounding box: (450, 370, 124, 34) │
96
+ │ [0:28] ✓ Coordinates: (512, 387) │
97
+ │ [0:28] ℹ️ Saving to cache (key: fe68cfe6...) │
98
+ │ [0:29] ✓ Element found and ready for interaction │
99
+ └────────────────────────────────────────────────────┘
100
+ ```
101
+
102
+ **Logged Information:**
103
+ - Screenshot capture timing
104
+ - Cache lookup results
105
+ - AI model inference time
106
+ - Confidence scores
107
+ - Element coordinates
108
+ - Cache storage
109
+
110
+ ## Cache Hit/Miss Tracking
111
+
112
+ Monitor cache performance in logs:
113
+
114
+ ```
115
+ Cache Performance Logs:
116
+ ┌────────────────────────────────────────────────────┐
117
+ │ [0:15] ⚡ Cache HIT: "login button" (12ms) │
118
+ │ [0:22] ⚡ Cache MISS: "email input" (analyzing...) │
119
+ │ [0:35] ⚡ Cache HIT: "password field" (8ms) │
120
+ │ [0:42] ⚡ Cache HIT: "submit button" (10ms) │
121
+ │ │
122
+ │ Cache Summary: │
123
+ │ • Hits: 3 (75%) │
124
+ │ • Misses: 1 (25%) │
125
+ │ • Time saved: ~6.2 seconds │
126
+ └────────────────────────────────────────────────────┘
127
+ ```
128
+
129
+ ## Test Step Logs
130
+
131
+ Detailed action execution:
132
+
133
+ ```
134
+ Action Execution:
135
+ ┌────────────────────────────────────────────────────┐
136
+ │ [0:19] ➤ testdriver.find('login button') │
137
+ │ [0:19] ℹ️ Locating element... │
138
+ │ [0:19] ✓ Found at (512, 387) │
139
+ │ │
140
+ │ [0:19] ➤ .click() │
141
+ │ [0:19] ℹ️ Moving mouse to (512, 387) │
142
+ │ [0:20] ℹ️ Mouse button down │
143
+ │ [0:20] ℹ️ Mouse button up │
144
+ │ [0:20] ✓ Click completed │
145
+ │ │
146
+ │ [0:22] ➤ testdriver.find('email input') │
147
+ │ [0:25] ✓ Found at (450, 290) │
148
+ │ │
149
+ │ [0:25] ➤ .type('user@example.com') │
150
+ │ [0:26] ℹ️ Typing: u │
151
+ │ [0:26] ℹ️ Typing: s │
152
+ │ [0:27] ℹ️ Typing: e │
153
+ │ [0:27] ℹ️ Typing: r │
154
+ │ ... (truncated for brevity) │
155
+ │ [0:29] ✓ Typed 17 characters │
156
+ └────────────────────────────────────────────────────┘
157
+ ```
158
+
159
+ ## Assertion Logs
160
+
161
+ Track test assertions:
162
+
163
+ ```
164
+ Assertions:
165
+ ┌────────────────────────────────────────────────────┐
166
+ │ [0:32] ➤ testdriver.assert('login successful') │
167
+ │ [0:32] ℹ️ Taking screenshot for assertion... │
168
+ │ [0:33] ℹ️ Sending to AI for verification... │
169
+ │ [0:35] ✓ Assertion passed with 96.2% confidence │
170
+ │ [0:35] ℹ️ Evidence: "Welcome, User" text visible │
171
+ │ │
172
+ │ [0:40] ➤ testdriver.assert('error message shows') │
173
+ │ [0:41] ℹ️ Taking screenshot for assertion... │
174
+ │ [0:42] ℹ️ Sending to AI for verification... │
175
+ │ [0:44] ✗ Assertion failed │
176
+ │ [0:44] ℹ️ Reason: No error message found │
177
+ │ [0:44] ℹ️ Screenshot saved for debugging │
178
+ └────────────────────────────────────────────────────┘
179
+ ```
180
+
181
+ ## Error and Stack Traces
182
+
183
+ Detailed error information:
184
+
185
+ ```
186
+ Error Details:
187
+ ┌────────────────────────────────────────────────────┐
188
+ │ [0:44] ✗ AssertionError: Element not found │
189
+ │ │
190
+ │ Expected: "error message" │
191
+ │ Context: Login form after submission │
192
+ │ Timeout: 30000ms │
193
+ │ │
194
+ │ Stack Trace: │
195
+ │ at TestDriver.assert (sdk.js:456) │
196
+ │ at login.test.js:23:18 │
197
+ │ at async Test.fn (vitest/run.js:125) │
198
+ │ │
199
+ │ Screenshot: /tmp/screenshot-abc123.png │
200
+ │ Replay URL: https://app.testdriver.ai/replay/... │
201
+ └────────────────────────────────────────────────────┘
202
+ ```
203
+
204
+ ## Configuring Log Output
205
+
206
+ Control log verbosity:
207
+
208
+ ```javascript
209
+ import { test } from 'vitest';
210
+ import { chrome } from 'testdriverai/presets';
211
+
212
+ test('with custom logging', async (context) => {
213
+ const { testdriver } = await chrome(context, {
214
+ url: 'https://example.com',
215
+ logLevel: 'debug', // 'error' | 'warn' | 'info' | 'debug'
216
+ verbose: true // Show detailed AI analysis logs
217
+ });
218
+
219
+ await testdriver.find('button').click();
220
+ });
221
+ ```
222
+
223
+ ## Log Filtering
224
+
225
+ Filter logs in the dashboard:
226
+
227
+ <Tabs>
228
+ <Tab title="By Level">
229
+ ```
230
+ Show only:
231
+ ☑ Errors
232
+ ☑ Warnings
233
+ ☐ Info
234
+ ☐ Debug
235
+ ```
236
+ </Tab>
237
+
238
+ <Tab title="By Category">
239
+ ```
240
+ Filter by:
241
+ ☑ AI Vision
242
+ ☑ Cache Operations
243
+ ☑ Actions
244
+ ☑ Assertions
245
+ ☐ Screenshots
246
+ ```
247
+ </Tab>
248
+
249
+ <Tab title="By Timestamp">
250
+ ```
251
+ Time range:
252
+ Full test duration
253
+ Last 30 seconds
254
+ Around error (±10s)
255
+ Custom range
256
+ ```
257
+ </Tab>
258
+
259
+ <Tab title="By Search">
260
+ ```
261
+ Search logs:
262
+ "element not found"
263
+ "cache hit"
264
+ "assertion"
265
+ Regular expressions supported
266
+ ```
267
+ </Tab>
268
+ </Tabs>
269
+
270
+ ## Export Logs
271
+
272
+ Download application logs:
273
+
274
+ <Tabs>
275
+ <Tab title="Plain Text">
276
+ ```
277
+ [0:00] INFO System info configured
278
+ [0:05] SUCCESS Connected to sandbox
279
+ [0:15] INFO Finding: "login button"
280
+ [0:18] SUCCESS Cache hit: login button
281
+ [0:19] SUCCESS Clicked login button
282
+ ```
283
+ </Tab>
284
+
285
+ <Tab title="JSON">
286
+ ```json
287
+ {
288
+ "logs": [
289
+ {
290
+ "timestamp": "0:00",
291
+ "level": "INFO",
292
+ "message": "System info configured"
293
+ },
294
+ {
295
+ "timestamp": "0:18",
296
+ "level": "SUCCESS",
297
+ "message": "Cache hit: login button",
298
+ "metadata": {
299
+ "cacheKey": "fe68cfe6...",
300
+ "matchTime": "12ms"
301
+ }
302
+ }
303
+ ]
304
+ }
305
+ ```
306
+ </Tab>
307
+
308
+ <Tab title="CSV">
309
+ ```csv
310
+ Timestamp,Level,Category,Message
311
+ 0:00,INFO,System,System info configured
312
+ 0:05,SUCCESS,Sandbox,Connected to sandbox
313
+ 0:15,INFO,Vision,Finding: "login button"
314
+ 0:18,SUCCESS,Cache,Cache hit: login button
315
+ ```
316
+ </Tab>
317
+ </Tabs>
318
+
319
+ ## Learn More
320
+
321
+ <CardGroup cols={2}>
322
+ <Card
323
+ title="Browser Logs"
324
+ icon="browser"
325
+ href="/v7/features/browser-logs"
326
+ >
327
+ Console output and JavaScript errors
328
+ </Card>
329
+
330
+ <Card
331
+ title="Network Monitoring"
332
+ icon="network-wired"
333
+ href="/v7/features/network-monitoring"
334
+ >
335
+ HTTP requests and responses
336
+ </Card>
337
+
338
+ <Card
339
+ title="System Performance"
340
+ icon="chart-line"
341
+ href="/v7/features/system-performance"
342
+ >
343
+ CPU, memory, and resource usage
344
+ </Card>
345
+
346
+ <Card
347
+ title="Test Replays"
348
+ icon="video"
349
+ href="/v7/features/test-replays"
350
+ >
351
+ Complete test execution videos
352
+ </Card>
353
+ </CardGroup>