testdriverai 7.2.9 → 7.2.10
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/.github/workflows/testdriver.yml +127 -0
- package/.testdriver/last-sandbox +7 -0
- package/agent/events.js +1 -0
- package/agent/index.js +71 -54
- package/agent/lib/sandbox.js +11 -1
- package/agents.md +393 -0
- package/debug/01-table-initial.png +0 -0
- package/debug/02-after-ai-explore.png +0 -0
- package/debug/02-after-scroll.png +0 -0
- package/docs/docs.json +93 -125
- package/docs/v7/_drafts/caching.mdx +2 -2
- package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
- package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
- package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
- package/docs/v7/_drafts/screenshot.mdx +155 -0
- package/docs/v7/_drafts/writing-tests.mdx +25 -0
- package/docs/v7/{api/act.mdx → ai.mdx} +27 -27
- package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
- package/docs/v7/aws-setup.mdx +338 -0
- package/docs/v7/caching.mdx +128 -0
- package/docs/v7/ci-cd.mdx +605 -0
- package/docs/v7/{api/click.mdx → click.mdx} +4 -4
- package/docs/v7/cloud.mdx +120 -0
- package/docs/v7/customizing-devices.mdx +129 -0
- package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
- package/docs/v7/enterprise.mdx +135 -0
- package/docs/v7/examples.mdx +5 -0
- package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
- package/docs/v7/{api/find.mdx → find.mdx} +17 -21
- package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
- package/docs/v7/generating-tests.mdx +32 -0
- package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
- package/docs/v7/locating-elements.mdx +71 -0
- package/docs/v7/making-assertions.mdx +32 -0
- package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
- package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
- package/docs/v7/performing-actions.mdx +51 -0
- package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
- package/docs/v7/quickstart.mdx +162 -0
- package/docs/v7/reusable-code.mdx +240 -0
- package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
- package/docs/v7/running-tests.mdx +181 -0
- package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
- package/docs/v7/secrets.mdx +115 -0
- package/docs/v7/self-hosted.mdx +66 -0
- package/docs/v7/{api/type.mdx → type.mdx} +3 -3
- package/docs/v7/variables.mdx +111 -0
- package/docs/v7/waiting-for-elements.mdx +66 -0
- package/docs/v7/what-is-testdriver.mdx +54 -0
- package/lib/vitest/hooks.mjs +80 -68
- package/package.json +1 -1
- package/sdk.d.ts +22 -9
- package/sdk.js +177 -44
- package/test/manual/reconnect-provision.test.mjs +49 -0
- package/test/manual/reconnect-signin.test.mjs +41 -0
- package/test/testdriver/ai.test.mjs +30 -0
- package/test/testdriver/setup/testHelpers.mjs +0 -1
- package/test/testdriver/windows-installer.test.mjs +61 -0
- package/tests/table-sort-enrollments.test.mjs +72 -0
- package/tests/table-sort-experiment.test.mjs +42 -0
- package/tests/table-sort-setup.test.mjs +59 -0
- package/vitest.config.mjs +1 -0
- package/docs/v7/api/assertions.mdx +0 -403
- package/docs/v7/features/ai-native.mdx +0 -413
- package/docs/v7/features/application-logs.mdx +0 -353
- package/docs/v7/features/browser-logs.mdx +0 -414
- package/docs/v7/features/cache-management.mdx +0 -402
- package/docs/v7/features/continuous-testing.mdx +0 -346
- package/docs/v7/features/data-driven-testing.mdx +0 -441
- package/docs/v7/features/easy-to-write.mdx +0 -280
- package/docs/v7/features/enterprise.mdx +0 -656
- package/docs/v7/features/fast.mdx +0 -406
- package/docs/v7/features/managed-sandboxes.mdx +0 -384
- package/docs/v7/features/network-monitoring.mdx +0 -568
- package/docs/v7/features/parallel-execution.mdx +0 -381
- package/docs/v7/features/powerful.mdx +0 -531
- package/docs/v7/features/sandbox-customization.mdx +0 -229
- package/docs/v7/features/stable.mdx +0 -473
- package/docs/v7/features/system-performance.mdx +0 -616
- package/docs/v7/features/test-analytics.mdx +0 -373
- package/docs/v7/features/test-cases.mdx +0 -393
- package/docs/v7/features/test-replays.mdx +0 -408
- package/docs/v7/features/test-reports.mdx +0 -308
- package/docs/v7/getting-started/debugging-tests.mdx +0 -382
- package/docs/v7/getting-started/quickstart.mdx +0 -90
- package/docs/v7/getting-started/running-tests.mdx +0 -173
- package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
- package/docs/v7/getting-started/writing-tests.mdx +0 -534
- package/docs/v7/overview/what-is-testdriver.mdx +0 -386
- package/docs/v7/presets/chrome-extension.mdx +0 -248
- package/docs/v7/presets/chrome.mdx +0 -300
- package/docs/v7/presets/electron.mdx +0 -460
- package/docs/v7/presets/vscode.mdx +0 -417
- package/docs/v7/presets/webapp.mdx +0 -393
- package/vitest.config.js +0 -18
- /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
- /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
- /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
- /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
- /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
- /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
- /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
- /package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -0
- /package/docs/v7/{api/elements.mdx → elements.mdx} +0 -0
- /package/docs/v7/{api/sandbox.mdx → sandbox.mdx} +0 -0
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Desktop Apps"
|
|
3
|
-
sidebarTitle: "Desktop Apps"
|
|
4
|
-
description: "Automatically launch and test Electron applications"
|
|
5
|
-
icon: "atom"
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
The `electron()` preset automatically sets up an Electron application with TestDriver and Dashcam recording. Perfect for testing desktop apps built with Electron.
|
|
11
|
-
|
|
12
|
-
<Note>
|
|
13
|
-
**Recommended Pattern (v7.1+):** Use `TestDriver()` hook + `provision.electron()` for more flexibility:
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
17
|
-
|
|
18
|
-
test('my test', async (context) => {
|
|
19
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
20
|
-
await testdriver.provision.electron({
|
|
21
|
-
appPath: './dist/my-app'
|
|
22
|
-
});
|
|
23
|
-
// ...
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
The `electron()` preset is still supported but the direct API provides better control and clearer lifecycle management.
|
|
28
|
-
</Note>
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
import { test } from 'vitest';
|
|
34
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
35
|
-
|
|
36
|
-
test('electron app test', async (context) => {
|
|
37
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
38
|
-
|
|
39
|
-
await testdriver.provision.electron({ appPath: './dist/my-app' });
|
|
40
|
-
|
|
41
|
-
await testdriver.find('main window').click();
|
|
42
|
-
await testdriver.find('File menu').click();
|
|
43
|
-
await testdriver.find('New Document').click();
|
|
44
|
-
});
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Signature
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
electron(context, options): Promise<ElectronResult>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Parameters
|
|
54
|
-
|
|
55
|
-
<ParamField path="context" type="object" required>
|
|
56
|
-
Vitest test context - automatically passed to your test function
|
|
57
|
-
</ParamField>
|
|
58
|
-
|
|
59
|
-
<ParamField path="options" type="object">
|
|
60
|
-
Configuration options for Electron
|
|
61
|
-
|
|
62
|
-
<Expandable title="properties">
|
|
63
|
-
<ParamField path="appPath" type="string" required>
|
|
64
|
-
Path to your Electron application executable or main file
|
|
65
|
-
</ParamField>
|
|
66
|
-
|
|
67
|
-
<ParamField path="args" type="string[]" default={[]}>
|
|
68
|
-
Additional command-line arguments to pass to Electron
|
|
69
|
-
</ParamField>
|
|
70
|
-
|
|
71
|
-
<ParamField path="dashcam" type="boolean" default={true}>
|
|
72
|
-
Enable Dashcam test recording
|
|
73
|
-
</ParamField>
|
|
74
|
-
|
|
75
|
-
<ParamField path="os" type="'linux' | 'mac' | 'windows'" default="linux">
|
|
76
|
-
Target operating system for the test
|
|
77
|
-
</ParamField>
|
|
78
|
-
</Expandable>
|
|
79
|
-
</ParamField>
|
|
80
|
-
|
|
81
|
-
### Returns
|
|
82
|
-
|
|
83
|
-
<ResponseField name="testdriver" type="TestDriver" required>
|
|
84
|
-
TestDriver instance ready to use
|
|
85
|
-
</ResponseField>
|
|
86
|
-
|
|
87
|
-
<ResponseField name="app" type="TestDriver" required>
|
|
88
|
-
Alias for testdriver (semantic clarity for Electron apps)
|
|
89
|
-
</ResponseField>
|
|
90
|
-
|
|
91
|
-
<ResponseField name="dashcam" type="Dashcam">
|
|
92
|
-
Dashcam instance for test recording (if enabled)
|
|
93
|
-
</ResponseField>
|
|
94
|
-
|
|
95
|
-
## Examples
|
|
96
|
-
|
|
97
|
-
### Basic Electron App
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
import { test } from 'vitest';
|
|
101
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
102
|
-
|
|
103
|
-
test('opens main window', async (context) => {
|
|
104
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
105
|
-
|
|
106
|
-
await testdriver.provision.electron({ appPath: './dist/my-electron-app' });
|
|
107
|
-
|
|
108
|
-
await testdriver.assert('Main window is visible');
|
|
109
|
-
await testdriver.find('Welcome message').click();
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### With Command-Line Arguments
|
|
114
|
-
|
|
115
|
-
```javascript
|
|
116
|
-
import { test } from 'vitest';
|
|
117
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
118
|
-
|
|
119
|
-
test('app with debug mode', async (context) => {
|
|
120
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
121
|
-
|
|
122
|
-
await testdriver.provision.electron({
|
|
123
|
-
appPath: './dist/app',
|
|
124
|
-
args: [
|
|
125
|
-
'--enable-logging',
|
|
126
|
-
'--debug',
|
|
127
|
-
'--user-data-dir=/tmp/test-data'
|
|
128
|
-
]
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await testdriver.find('Debug panel').click();
|
|
132
|
-
await testdriver.assert('Debug information is visible');
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Menu Navigation
|
|
137
|
-
|
|
138
|
-
```javascript
|
|
139
|
-
import { test } from 'vitest';
|
|
140
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
141
|
-
|
|
142
|
-
test('file menu operations', async (context) => {
|
|
143
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
144
|
-
|
|
145
|
-
await testdriver.provision.electron({ appPath: './dist/editor-app' });
|
|
146
|
-
|
|
147
|
-
// Open File menu
|
|
148
|
-
await testdriver.find('File').click();
|
|
149
|
-
await testdriver.find('New File').click();
|
|
150
|
-
|
|
151
|
-
// Verify new file created
|
|
152
|
-
await testdriver.assert('Untitled document is open');
|
|
153
|
-
|
|
154
|
-
// Save file
|
|
155
|
-
await testdriver.find('File').click();
|
|
156
|
-
await testdriver.find('Save As').click();
|
|
157
|
-
await testdriver.type('test-document.txt');
|
|
158
|
-
await testdriver.pressKeys(['enter']);
|
|
159
|
-
|
|
160
|
-
await testdriver.assert('File saved successfully');
|
|
161
|
-
});
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Testing on Different Platforms
|
|
165
|
-
|
|
166
|
-
```javascript
|
|
167
|
-
import { test } from 'vitest';
|
|
168
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
169
|
-
|
|
170
|
-
test('windows electron app', async (context) => {
|
|
171
|
-
const testdriver = TestDriver(context, { headless: true, os: 'windows' });
|
|
172
|
-
|
|
173
|
-
await testdriver.provision.electron({
|
|
174
|
-
appPath: 'C:\\Program Files\\MyApp\\MyApp.exe'
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await testdriver.find('Start button').click();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('mac electron app', async (context) => {
|
|
181
|
-
const testdriver = TestDriver(context, { headless: true, os: 'mac' });
|
|
182
|
-
|
|
183
|
-
await testdriver.provision.electron({
|
|
184
|
-
appPath: '/Applications/MyApp.app/Contents/MacOS/MyApp'
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
await testdriver.find('Start button').click();
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Preferences and Settings
|
|
192
|
-
|
|
193
|
-
```javascript
|
|
194
|
-
import { test } from 'vitest';
|
|
195
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
196
|
-
|
|
197
|
-
test('configure app settings', async (context) => {
|
|
198
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
199
|
-
|
|
200
|
-
await testdriver.provision.electron({ appPath: './dist/my-app' });
|
|
201
|
-
|
|
202
|
-
// Open preferences
|
|
203
|
-
await testdriver.find('Settings').click();
|
|
204
|
-
|
|
205
|
-
// Change theme
|
|
206
|
-
await testdriver.find('Appearance').click();
|
|
207
|
-
await testdriver.find('Dark mode toggle').click();
|
|
208
|
-
|
|
209
|
-
// Verify change
|
|
210
|
-
await testdriver.assert('Dark mode is enabled');
|
|
211
|
-
|
|
212
|
-
// Save settings
|
|
213
|
-
await testdriver.find('Save button').click();
|
|
214
|
-
|
|
215
|
-
await testdriver.assert('Settings saved');
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Window Management
|
|
220
|
-
|
|
221
|
-
```javascript
|
|
222
|
-
import { test } from 'vitest';
|
|
223
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
224
|
-
|
|
225
|
-
test('multiple windows', async (context) => {
|
|
226
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
227
|
-
|
|
228
|
-
await testdriver.provision.electron({ appPath: './dist/multi-window-app' });
|
|
229
|
-
|
|
230
|
-
// Open new window
|
|
231
|
-
await testdriver.find('File').click();
|
|
232
|
-
await testdriver.find('New Window').click();
|
|
233
|
-
|
|
234
|
-
// Switch between windows
|
|
235
|
-
await testdriver.find('second window').click();
|
|
236
|
-
await testdriver.assert('Second window is focused');
|
|
237
|
-
|
|
238
|
-
// Close window
|
|
239
|
-
await testdriver.find('Close button').click();
|
|
240
|
-
|
|
241
|
-
await testdriver.assert('Window closed');
|
|
242
|
-
});
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### Form Interaction
|
|
246
|
-
|
|
247
|
-
```javascript
|
|
248
|
-
import { test } from 'vitest';
|
|
249
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
250
|
-
|
|
251
|
-
test('form submission', async (context) => {
|
|
252
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
253
|
-
|
|
254
|
-
await testdriver.provision.electron({ appPath: './dist/form-app' });
|
|
255
|
-
|
|
256
|
-
// Fill form
|
|
257
|
-
await testdriver.find('Name input').type('John Doe');
|
|
258
|
-
await testdriver.find('Email input').type('john@example.com');
|
|
259
|
-
await testdriver.find('Phone input').type('555-1234');
|
|
260
|
-
|
|
261
|
-
// Select dropdown
|
|
262
|
-
await testdriver.find('Country dropdown').click();
|
|
263
|
-
await testdriver.find('United States').click();
|
|
264
|
-
|
|
265
|
-
// Check checkbox
|
|
266
|
-
await testdriver.find('Terms and conditions').click();
|
|
267
|
-
|
|
268
|
-
// Submit
|
|
269
|
-
await testdriver.find('Submit button').click();
|
|
270
|
-
|
|
271
|
-
await testdriver.assert('Form submitted successfully');
|
|
272
|
-
|
|
273
|
-
// Dashcam captures entire interaction
|
|
274
|
-
});
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
## What It Does
|
|
278
|
-
|
|
279
|
-
When you call `electron()`, it automatically:
|
|
280
|
-
|
|
281
|
-
1. **Initializes TestDriver** - Creates and connects to sandbox
|
|
282
|
-
2. **Sets up Dashcam** - Authenticates and starts recording (if enabled)
|
|
283
|
-
3. **Launches Electron** - Starts your app with specified arguments
|
|
284
|
-
4. **Waits for Ready** - Ensures app is focused and windows are loaded
|
|
285
|
-
5. **Returns Instances** - Provides ready-to-use testdriver, app alias, and dashcam
|
|
286
|
-
|
|
287
|
-
At test end:
|
|
288
|
-
- Dashcam automatically stops and saves replay URL
|
|
289
|
-
- TestDriver automatically disconnects
|
|
290
|
-
- All cleanup is handled for you
|
|
291
|
-
|
|
292
|
-
## Common Patterns
|
|
293
|
-
|
|
294
|
-
### IPC Communication Testing
|
|
295
|
-
|
|
296
|
-
```javascript
|
|
297
|
-
test('ipc events', async (context) => {
|
|
298
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
299
|
-
|
|
300
|
-
await testdriver.provision.electron({ appPath: './dist/ipc-app' });
|
|
301
|
-
|
|
302
|
-
// Trigger IPC event from renderer
|
|
303
|
-
await testdriver.find('Send Message button').click();
|
|
304
|
-
|
|
305
|
-
// Verify main process response
|
|
306
|
-
await testdriver.assert('Response received from main process');
|
|
307
|
-
});
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### Notification Testing
|
|
311
|
-
|
|
312
|
-
```javascript
|
|
313
|
-
test('system notifications', async (context) => {
|
|
314
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
315
|
-
|
|
316
|
-
await testdriver.provision.electron({ appPath: './dist/notification-app' });
|
|
317
|
-
|
|
318
|
-
await testdriver.find('Show Notification').click();
|
|
319
|
-
await testdriver.assert('System notification appears');
|
|
320
|
-
});
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Tray Icon Interaction
|
|
324
|
-
|
|
325
|
-
```javascript
|
|
326
|
-
test('system tray', async (context) => {
|
|
327
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
328
|
-
|
|
329
|
-
await testdriver.provision.electron({ appPath: './dist/tray-app' });
|
|
330
|
-
|
|
331
|
-
// Click tray icon
|
|
332
|
-
await testdriver.find('app tray icon').click();
|
|
333
|
-
|
|
334
|
-
// Interact with tray menu
|
|
335
|
-
await testdriver.find('Show Window').click();
|
|
336
|
-
|
|
337
|
-
await testdriver.assert('Main window appears');
|
|
338
|
-
});
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### Auto-Update Flow
|
|
342
|
-
|
|
343
|
-
```javascript
|
|
344
|
-
test('app update', async (context) => {
|
|
345
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
346
|
-
|
|
347
|
-
await testdriver.provision.electron({
|
|
348
|
-
appPath: './dist/updatable-app',
|
|
349
|
-
args: ['--check-updates']
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
await testdriver.find('Check for Updates').click();
|
|
353
|
-
await testdriver.assert('Checking for updates message');
|
|
354
|
-
|
|
355
|
-
// Assuming update is available
|
|
356
|
-
await testdriver.find('Download Update').click();
|
|
357
|
-
await testdriver.assert('Update downloaded');
|
|
358
|
-
});
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
## Development Paths
|
|
362
|
-
|
|
363
|
-
### Common Development Paths
|
|
364
|
-
|
|
365
|
-
```javascript
|
|
366
|
-
// Electron Forge
|
|
367
|
-
appPath: './out/my-app-linux-x64/my-app'
|
|
368
|
-
|
|
369
|
-
// Electron Builder
|
|
370
|
-
appPath: './dist/linux-unpacked/my-app'
|
|
371
|
-
|
|
372
|
-
// Direct execution
|
|
373
|
-
appPath: './node_modules/.bin/electron'
|
|
374
|
-
args: ['./main.js']
|
|
375
|
-
|
|
376
|
-
// Packaged app (Windows)
|
|
377
|
-
appPath: 'C:\\Program Files\\MyApp\\MyApp.exe'
|
|
378
|
-
|
|
379
|
-
// Packaged app (macOS)
|
|
380
|
-
appPath: '/Applications/MyApp.app/Contents/MacOS/MyApp'
|
|
381
|
-
|
|
382
|
-
// Packaged app (Linux)
|
|
383
|
-
appPath: '/opt/MyApp/my-app'
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
## Using with provision()
|
|
387
|
-
|
|
388
|
-
The `electron()` preset can also be called via the unified `provision()` function:
|
|
389
|
-
|
|
390
|
-
```javascript
|
|
391
|
-
import { provision } from 'testdriverai/presets';
|
|
392
|
-
|
|
393
|
-
test('using provision', async (context) => {
|
|
394
|
-
const { app } = await provision('electron', {
|
|
395
|
-
appPath: './dist/my-app'
|
|
396
|
-
}, context);
|
|
397
|
-
|
|
398
|
-
// Same functionality as electron() directly
|
|
399
|
-
});
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
## Error Handling
|
|
403
|
-
|
|
404
|
-
```javascript
|
|
405
|
-
test('handles missing app path', async (context) => {
|
|
406
|
-
try {
|
|
407
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
408
|
-
await testdriver.provision.electron({ appPath: '/nonexistent/path' });
|
|
409
|
-
} catch (error) {
|
|
410
|
-
// Cleanup still happens automatically
|
|
411
|
-
expect(error.message).toContain('appPath');
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
test('handles app crashes', async (context) => {
|
|
416
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
417
|
-
|
|
418
|
-
await testdriver.provision.electron({ appPath: './dist/my-app' });
|
|
419
|
-
|
|
420
|
-
try {
|
|
421
|
-
// Trigger something that might crash
|
|
422
|
-
await testdriver.find('Crash button').click();
|
|
423
|
-
} catch (error) {
|
|
424
|
-
// Dashcam still saves replay of crash
|
|
425
|
-
console.error('App crashed:', error);
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
## Debugging Tips
|
|
431
|
-
|
|
432
|
-
1. **Enable Electron DevTools** - Pass `--enable-logging` in args
|
|
433
|
-
2. **Use Dashcam** - Review test recordings to see what happened
|
|
434
|
-
3. **Custom User Data** - Use `--user-data-dir` for isolated testing
|
|
435
|
-
4. **Remote Debugging** - Use `--remote-debugging-port=9222`
|
|
436
|
-
|
|
437
|
-
```javascript
|
|
438
|
-
test('with debugging enabled', async (context) => {
|
|
439
|
-
const testdriver = TestDriver(context, { headless: true });
|
|
440
|
-
|
|
441
|
-
await testdriver.provision.electron({
|
|
442
|
-
appPath: './dist/my-app',
|
|
443
|
-
args: [
|
|
444
|
-
'--enable-logging',
|
|
445
|
-
'--remote-debugging-port=9222',
|
|
446
|
-
'--user-data-dir=/tmp/test-profile'
|
|
447
|
-
]
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
// Test with full debugging capabilities
|
|
451
|
-
});
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
## See Also
|
|
455
|
-
|
|
456
|
-
- [Provision API](/v7/progressive-apis/PROVISION) - Overview of all presets
|
|
457
|
-
- [Chrome Preset](/v7/presets/chrome) - Testing web applications
|
|
458
|
-
- [VS Code Preset](/v7/presets/vscode) - Testing VS Code extensions
|
|
459
|
-
- [Vitest Integration](/v7/guides/vitest) - Complete Vitest setup guide
|
|
460
|
-
- [Hooks API](/v7/progressive-apis/HOOKS) - Manual lifecycle control
|