testdriverai 7.0.0 → 7.1.0
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/AGENTS.md +550 -0
- package/CODEOWNERS +0 -1
- package/README.md +126 -0
- package/agent/index.js +43 -18
- package/agent/lib/commands.js +794 -135
- package/agent/lib/redraw.js +124 -39
- package/agent/lib/sandbox.js +10 -1
- package/agent/lib/sdk.js +21 -0
- package/docs/MIGRATION.md +425 -0
- package/docs/PRESETS.md +210 -0
- package/docs/docs.json +91 -37
- package/docs/guide/best-practices-polling.mdx +154 -0
- package/docs/v7/api/dashcam.mdx +497 -0
- package/docs/v7/api/doubleClick.mdx +102 -0
- package/docs/v7/api/mouseDown.mdx +161 -0
- package/docs/v7/api/mouseUp.mdx +164 -0
- package/docs/v7/api/rightClick.mdx +123 -0
- package/docs/v7/getting-started/configuration.mdx +380 -0
- package/docs/v7/getting-started/quickstart.mdx +273 -140
- package/docs/v7/guides/best-practices.mdx +486 -0
- package/docs/v7/guides/caching-ai.mdx +215 -0
- package/docs/v7/guides/caching-selectors.mdx +292 -0
- package/docs/v7/guides/caching.mdx +366 -0
- package/docs/v7/guides/ci-cd/azure.mdx +587 -0
- package/docs/v7/guides/ci-cd/circleci.mdx +523 -0
- package/docs/v7/guides/ci-cd/github-actions.mdx +457 -0
- package/docs/v7/guides/ci-cd/gitlab.mdx +498 -0
- package/docs/v7/guides/ci-cd/jenkins.mdx +664 -0
- package/docs/v7/guides/ci-cd/travis.mdx +438 -0
- package/docs/v7/guides/debugging.mdx +349 -0
- package/docs/v7/guides/faq.mdx +393 -0
- package/docs/v7/guides/performance.mdx +517 -0
- package/docs/v7/guides/troubleshooting.mdx +526 -0
- package/docs/v7/guides/vitest-plugin.mdx +477 -0
- package/docs/v7/guides/vitest.mdx +535 -0
- package/docs/v7/platforms/linux.mdx +308 -0
- package/docs/v7/platforms/macos.mdx +433 -0
- package/docs/v7/platforms/windows.mdx +430 -0
- package/docs/v7/presets/chrome-extension.mdx +223 -0
- package/docs/v7/presets/chrome.mdx +287 -0
- package/docs/v7/presets/electron.mdx +435 -0
- package/docs/v7/presets/vscode.mdx +398 -0
- package/docs/v7/presets/webapp.mdx +396 -0
- package/docs/v7/progressive-apis/CORE.md +459 -0
- package/docs/v7/progressive-apis/HOOKS.md +360 -0
- package/docs/v7/progressive-apis/PROGRESSIVE_DISCLOSURE.md +230 -0
- package/docs/v7/progressive-apis/PROVISION.md +266 -0
- package/interfaces/vitest-plugin.mjs +186 -100
- package/package.json +12 -1
- package/sdk.d.ts +335 -42
- package/sdk.js +756 -95
- package/src/core/Dashcam.js +469 -0
- package/src/core/index.d.ts +150 -0
- package/src/core/index.js +12 -0
- package/src/presets/index.mjs +331 -0
- package/src/vitest/extended.mjs +108 -0
- package/src/vitest/hooks.d.ts +119 -0
- package/src/vitest/hooks.mjs +298 -0
- package/src/vitest/index.mjs +64 -0
- package/src/vitest/lifecycle.mjs +277 -0
- package/src/vitest/utils.mjs +150 -0
- package/test/dashcam.test.js +137 -0
- package/testdriver/acceptance-sdk/assert.test.mjs +13 -31
- package/testdriver/acceptance-sdk/auto-cache-key-demo.test.mjs +56 -0
- package/testdriver/acceptance-sdk/chrome-extension.test.mjs +89 -0
- package/testdriver/acceptance-sdk/drag-and-drop.test.mjs +7 -19
- package/testdriver/acceptance-sdk/element-not-found.test.mjs +6 -19
- package/testdriver/acceptance-sdk/exec-js.test.mjs +6 -18
- package/testdriver/acceptance-sdk/exec-output.test.mjs +8 -20
- package/testdriver/acceptance-sdk/exec-pwsh.test.mjs +13 -25
- package/testdriver/acceptance-sdk/focus-window.test.mjs +8 -20
- package/testdriver/acceptance-sdk/formatted-logging.test.mjs +5 -20
- package/testdriver/acceptance-sdk/hooks-example.test.mjs +38 -0
- package/testdriver/acceptance-sdk/hover-image.test.mjs +10 -19
- package/testdriver/acceptance-sdk/hover-text-with-description.test.mjs +7 -19
- package/testdriver/acceptance-sdk/hover-text.test.mjs +5 -19
- package/testdriver/acceptance-sdk/match-image.test.mjs +7 -19
- package/testdriver/acceptance-sdk/presets-example.test.mjs +87 -0
- package/testdriver/acceptance-sdk/press-keys.test.mjs +5 -19
- package/testdriver/acceptance-sdk/prompt.test.mjs +6 -18
- package/testdriver/acceptance-sdk/scroll-keyboard.test.mjs +6 -20
- package/testdriver/acceptance-sdk/scroll-until-image.test.mjs +6 -18
- package/testdriver/acceptance-sdk/scroll-until-text.test.mjs +9 -23
- package/testdriver/acceptance-sdk/scroll.test.mjs +12 -21
- package/testdriver/acceptance-sdk/setup/testHelpers.mjs +124 -352
- package/testdriver/acceptance-sdk/sully-ai.test.mjs +234 -0
- package/testdriver/acceptance-sdk/test-console-logs.test.mjs +42 -0
- package/testdriver/acceptance-sdk/type.test.mjs +19 -58
- package/vitest.config.mjs +1 -0
- package/.vscode/mcp.json +0 -9
- package/MIGRATION.md +0 -389
- package/PLUGIN_MIGRATION.md +0 -222
- package/PROMPT_CACHE.md +0 -200
- package/SDK_LOGGING.md +0 -222
- package/SDK_MIGRATION.md +0 -474
- package/SDK_README.md +0 -1122
- package/debug-screenshot-1763401388589.png +0 -0
- package/examples/run-tests-with-recording.sh +0 -70
- package/examples/screenshot-example.js +0 -63
- package/examples/sdk-awesome-logs-demo.js +0 -177
- package/examples/sdk-cache-thresholds.js +0 -96
- package/examples/sdk-element-properties.js +0 -155
- package/examples/sdk-simple-example.js +0 -65
- package/examples/test-recording-example.test.js +0 -166
- package/mcp-server/AI_GUIDELINES.md +0 -57
- package/test-find-api.js +0 -73
- package/test-prompt-cache.js +0 -96
- package/test-sandbox-render.js +0 -28
- package/test-sdk-methods.js +0 -15
- package/test-sdk-refactor.js +0 -53
- package/test-stack-trace.mjs +0 -57
- package/testdriver/acceptance-sdk/setup/lifecycleHelpers.mjs +0 -239
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Provision API
|
|
2
|
+
|
|
3
|
+
The `provision()` function is the easiest way to set up TestDriver for common applications. It automatically handles TestDriver initialization, application launching, and Dashcam recording.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { test } from 'vitest';
|
|
9
|
+
import { provision } from 'testdriverai/presets';
|
|
10
|
+
|
|
11
|
+
test('my test', async (context) => {
|
|
12
|
+
const { testdriver } = await provision('chrome', {
|
|
13
|
+
url: 'https://example.com'
|
|
14
|
+
}, context);
|
|
15
|
+
|
|
16
|
+
await testdriver.find('Login button').click();
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
provision(appType, options, context)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Parameters:**
|
|
27
|
+
- `appType` - Application type: `'chrome'`, `'vscode'`, `'electron'`, or `'webapp'`
|
|
28
|
+
- `options` - Configuration options (varies by app type)
|
|
29
|
+
- `context` - Vitest test context (from your test function parameter)
|
|
30
|
+
|
|
31
|
+
**Returns:**
|
|
32
|
+
- `testdriver` - TestDriver instance ready to use
|
|
33
|
+
- `dashcam` - Dashcam instance (if enabled)
|
|
34
|
+
- Additional app-specific properties (like `vscode`, `app`)
|
|
35
|
+
|
|
36
|
+
## Application Types
|
|
37
|
+
|
|
38
|
+
### Chrome Browser
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const { testdriver } = await provision('chrome', {
|
|
42
|
+
url: 'https://myapp.com',
|
|
43
|
+
maximized: true, // Start maximized (default: true)
|
|
44
|
+
guest: true, // Use guest mode (default: true)
|
|
45
|
+
dashcam: true, // Enable Dashcam (default: true)
|
|
46
|
+
os: 'linux' // Target OS (default: 'linux')
|
|
47
|
+
}, context);
|
|
48
|
+
|
|
49
|
+
await testdriver.find('username').type('user@example.com');
|
|
50
|
+
await testdriver.find('Login').click();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Options:**
|
|
54
|
+
- `url` - URL to navigate to (default: 'http://testdriver-sandbox.vercel.app/')
|
|
55
|
+
- `maximized` - Start browser maximized (default: `true`)
|
|
56
|
+
- `guest` - Use guest/incognito mode (default: `true`)
|
|
57
|
+
- `dashcam` - Enable Dashcam recording (default: `true`)
|
|
58
|
+
- `os` - Target OS: `'linux'`, `'mac'`, or `'windows'` (default: `'linux'`)
|
|
59
|
+
|
|
60
|
+
**Returns:**
|
|
61
|
+
- `testdriver` - TestDriver instance
|
|
62
|
+
- `dashcam` - Dashcam instance (if enabled)
|
|
63
|
+
|
|
64
|
+
### VS Code
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const { testdriver, vscode } = await provision('vscode', {
|
|
68
|
+
workspace: '/path/to/project',
|
|
69
|
+
extensions: ['ms-python.python'],
|
|
70
|
+
dashcam: true,
|
|
71
|
+
os: 'linux'
|
|
72
|
+
}, context);
|
|
73
|
+
|
|
74
|
+
await vscode.find('File menu').click();
|
|
75
|
+
await vscode.find('New File').click();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Options:**
|
|
79
|
+
- `workspace` - Workspace/folder path to open (optional)
|
|
80
|
+
- `extensions` - Array of extension IDs to install (optional)
|
|
81
|
+
- `dashcam` - Enable Dashcam recording (default: `true`)
|
|
82
|
+
- `os` - Target OS (default: `'linux'`)
|
|
83
|
+
|
|
84
|
+
**Returns:**
|
|
85
|
+
- `testdriver` - TestDriver instance
|
|
86
|
+
- `vscode` - Alias for testdriver (semantic clarity)
|
|
87
|
+
- `dashcam` - Dashcam instance (if enabled)
|
|
88
|
+
|
|
89
|
+
### Electron
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
const { testdriver, app } = await provision('electron', {
|
|
93
|
+
appPath: '/path/to/app',
|
|
94
|
+
args: ['--enable-logging'],
|
|
95
|
+
dashcam: true,
|
|
96
|
+
os: 'linux'
|
|
97
|
+
}, context);
|
|
98
|
+
|
|
99
|
+
await app.find('main window').click();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Options:**
|
|
103
|
+
- `appPath` - Path to Electron application (required)
|
|
104
|
+
- `args` - Additional command-line arguments (optional)
|
|
105
|
+
- `dashcam` - Enable Dashcam recording (default: `true`)
|
|
106
|
+
- `os` - Target OS (default: `'linux'`)
|
|
107
|
+
|
|
108
|
+
**Returns:**
|
|
109
|
+
- `testdriver` - TestDriver instance
|
|
110
|
+
- `app` - Alias for testdriver (semantic clarity)
|
|
111
|
+
- `dashcam` - Dashcam instance (if enabled)
|
|
112
|
+
|
|
113
|
+
### Web App
|
|
114
|
+
|
|
115
|
+
Generic wrapper for web applications (currently uses Chrome):
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
const { testdriver } = await provision('webapp', {
|
|
119
|
+
url: 'https://example.com',
|
|
120
|
+
browser: 'chrome' // Only 'chrome' supported currently
|
|
121
|
+
}, context);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Complete Example
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
import { describe, it, expect } from 'vitest';
|
|
128
|
+
import { provision } from 'testdriverai/presets';
|
|
129
|
+
|
|
130
|
+
describe('Login Flow', () => {
|
|
131
|
+
it('should login successfully', async (context) => {
|
|
132
|
+
// Provision Chrome with your app
|
|
133
|
+
const { testdriver, dashcam } = await provision('chrome', {
|
|
134
|
+
url: 'https://myapp.com/login',
|
|
135
|
+
maximized: true
|
|
136
|
+
}, context);
|
|
137
|
+
|
|
138
|
+
// Interact with the application
|
|
139
|
+
await testdriver.find('email input').type('user@example.com');
|
|
140
|
+
await testdriver.find('password input').type('password123');
|
|
141
|
+
await testdriver.find('Login button').click();
|
|
142
|
+
|
|
143
|
+
// Verify results
|
|
144
|
+
const result = await testdriver.assert('Welcome message is visible');
|
|
145
|
+
expect(result).toBeTruthy();
|
|
146
|
+
|
|
147
|
+
// Dashcam automatically stops and saves replay at test end
|
|
148
|
+
// No cleanup needed - handled automatically!
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## How It Works
|
|
154
|
+
|
|
155
|
+
When you call `provision()`:
|
|
156
|
+
|
|
157
|
+
1. **Creates TestDriver client** - Initializes and connects to sandbox
|
|
158
|
+
2. **Sets up Dashcam** - Authenticates and starts recording (if enabled)
|
|
159
|
+
3. **Launches application** - Opens the specified app with your configuration
|
|
160
|
+
4. **Focuses window** - Ensures the app is ready for interaction
|
|
161
|
+
5. **Returns ready-to-use instances** - Everything is set up and ready
|
|
162
|
+
|
|
163
|
+
At test end:
|
|
164
|
+
- Dashcam automatically stops and saves replay URL
|
|
165
|
+
- TestDriver automatically disconnects
|
|
166
|
+
- All cleanup is handled for you
|
|
167
|
+
|
|
168
|
+
## Automatic Lifecycle
|
|
169
|
+
|
|
170
|
+
The `provision()` function uses Vitest hooks under the hood to manage the entire lifecycle:
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// ✅ This:
|
|
174
|
+
const { testdriver } = await provision('chrome', { url }, context);
|
|
175
|
+
|
|
176
|
+
// Is equivalent to manually doing:
|
|
177
|
+
const client = new TestDriver(apiKey, { os: 'linux' });
|
|
178
|
+
await client.auth();
|
|
179
|
+
await client.connect();
|
|
180
|
+
|
|
181
|
+
const dashcam = new Dashcam(client);
|
|
182
|
+
await dashcam.auth();
|
|
183
|
+
await dashcam.start();
|
|
184
|
+
|
|
185
|
+
await client.exec('sh', 'google-chrome --start-maximized --guest "https://example.com" &', 30000);
|
|
186
|
+
await client.focusApplication('Google Chrome');
|
|
187
|
+
|
|
188
|
+
// ... your test code ...
|
|
189
|
+
|
|
190
|
+
await dashcam.stop();
|
|
191
|
+
await client.disconnect();
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
That's **15+ lines of boilerplate** reduced to **1 line**!
|
|
195
|
+
|
|
196
|
+
## TypeScript Support
|
|
197
|
+
|
|
198
|
+
Full TypeScript definitions included:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { provision } from 'testdriverai/presets';
|
|
202
|
+
|
|
203
|
+
test('typed test', async (context) => {
|
|
204
|
+
const { testdriver } = await provision('chrome', {
|
|
205
|
+
url: 'https://example.com',
|
|
206
|
+
maximized: true,
|
|
207
|
+
os: 'linux' // ✅ Type-safe: only 'linux' | 'mac' | 'windows'
|
|
208
|
+
}, context);
|
|
209
|
+
|
|
210
|
+
// ✅ Full autocomplete for testdriver methods
|
|
211
|
+
await testdriver.find('button').click();
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Direct Preset Functions
|
|
216
|
+
|
|
217
|
+
You can also use the individual preset functions directly:
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
import { chrome, vscode, electron } from 'testdriverai/presets';
|
|
221
|
+
|
|
222
|
+
// Same as provision('chrome', options, context)
|
|
223
|
+
const { testdriver } = await chrome(context, {
|
|
224
|
+
url: 'https://example.com'
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Same as provision('vscode', options, context)
|
|
228
|
+
const { vscode } = await vscode(context, {
|
|
229
|
+
workspace: '/path/to/project'
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
These are available for when you prefer explicit function names.
|
|
234
|
+
|
|
235
|
+
## Best Practices
|
|
236
|
+
|
|
237
|
+
1. **Always pass context** - Required for automatic cleanup
|
|
238
|
+
2. **Enable dashcam** - Great for debugging test failures
|
|
239
|
+
3. **Use descriptive variables** - `testdriver`, `vscode`, `app` based on what you're testing
|
|
240
|
+
4. **Leverage TypeScript** - Get autocomplete and type safety
|
|
241
|
+
5. **Keep URLs in config** - Use environment variables for different environments
|
|
242
|
+
|
|
243
|
+
## Error Handling
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
test('handles errors gracefully', async (context) => {
|
|
247
|
+
try {
|
|
248
|
+
const { testdriver } = await provision('chrome', {
|
|
249
|
+
url: 'https://example.com'
|
|
250
|
+
}, context);
|
|
251
|
+
|
|
252
|
+
await testdriver.find('button').click();
|
|
253
|
+
} catch (error) {
|
|
254
|
+
// Cleanup still happens automatically
|
|
255
|
+
console.error('Test failed:', error);
|
|
256
|
+
throw error; // Re-throw to mark test as failed
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## See Also
|
|
262
|
+
|
|
263
|
+
- [Hooks API](./HOOKS.md) - For more control over lifecycle
|
|
264
|
+
- [Core Classes](./CORE.md) - For full manual control
|
|
265
|
+
- [Migration Guide](../MIGRATION.md) - Upgrading from v6
|
|
266
|
+
- [Examples](../../testdriver/acceptance-sdk/presets-example.test.mjs) - Working examples
|