testdriverai 7.9.0-test.4 → 7.9.0-test.40
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/agent/lib/sandbox.js +36 -5
- package/agent/lib/sdk.js +4 -4
- package/ai/skills/testdriver-enterprise/SKILL.md +2 -109
- package/ai/skills/testdriver-hosted/SKILL.md +156 -0
- package/ai/skills/testdriver-mcp/SKILL.md +2 -2
- package/ai/skills/testdriver-quickstart/SKILL.md +30 -2
- package/ai/skills/testdriver-self-hosted/SKILL.md +125 -43
- package/ai/skills/testdriver-test-results-json/SKILL.md +257 -0
- package/docs/_scripts/generate-examples.js +127 -60
- package/docs/docs.json +27 -28
- package/docs/v7/examples/ai.mdx +4 -3
- package/docs/v7/examples/assert.mdx +19 -4
- package/docs/v7/examples/chrome-extension.mdx +36 -29
- package/docs/v7/examples/element-not-found.mdx +2 -1
- package/docs/v7/examples/exec-output.mdx +3 -4
- package/docs/v7/examples/exec-pwsh.mdx +3 -4
- package/docs/v7/examples/findall-coffee-icons.mdx +88 -0
- package/docs/v7/examples/focus-window.mdx +3 -4
- package/docs/v7/examples/hover-image.mdx +4 -3
- package/docs/v7/examples/hover-text-with-description.mdx +104 -0
- package/docs/v7/examples/hover-text.mdx +4 -3
- package/docs/v7/examples/installer.mdx +5 -4
- package/docs/v7/examples/launch-vscode-linux.mdx +3 -7
- package/docs/v7/examples/match-image.mdx +3 -2
- package/docs/v7/examples/parse.mdx +66 -0
- package/docs/v7/examples/press-keys.mdx +8 -14
- package/docs/v7/examples/scroll-keyboard.mdx +4 -3
- package/docs/v7/examples/scroll-until-image.mdx +3 -2
- package/docs/v7/examples/scroll.mdx +6 -14
- package/docs/v7/examples/type.mdx +1 -5
- package/docs/v7/examples/windows-installer.mdx +10 -4
- package/interfaces/vitest-plugin.mjs +2 -2
- package/package.json +1 -1
- package/setup/aws/install-dev-runner.sh +7 -2
- package/setup/aws/spawn-runner.sh +12 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:test-results-json
|
|
3
|
+
description: Per-test JSON result files with metadata, versions, and infrastructure details
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from test-results-json.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
TestDriver automatically writes a JSON result file for each test case after it finishes. These files contain comprehensive metadata about the test run, including SDK and runner versions, infrastructure details, interaction statistics, and links to recordings.
|
|
10
|
+
|
|
11
|
+
Result files are written to:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
.testdriver/results/<testFile>/<testName>.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For example, a test file `tests/login.test.mjs` with a test named `"should log in"` produces:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
.testdriver/results/tests/login.test.mjs/should_log_in.json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<Note>
|
|
24
|
+
Test names are sanitized for filesystem use — special characters are replaced with underscores and names are truncated to 200 characters.
|
|
25
|
+
</Note>
|
|
26
|
+
|
|
27
|
+
## Enabling
|
|
28
|
+
|
|
29
|
+
No configuration is required. The JSON files are written automatically by the TestDriver Vitest reporter plugin whenever tests run.
|
|
30
|
+
|
|
31
|
+
## JSON Schema
|
|
32
|
+
|
|
33
|
+
Each result file is organized into logical groups:
|
|
34
|
+
|
|
35
|
+
### `versions`
|
|
36
|
+
|
|
37
|
+
| Field | Type | Description |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `versions.sdk` | `string \| null` | TestDriver SDK version (e.g. `"7.8.0"`) |
|
|
40
|
+
| `versions.vitest` | `string \| null` | Vitest version used to run the test |
|
|
41
|
+
| `versions.api` | `string \| null` | TestDriver API server version |
|
|
42
|
+
| `versions.runnerBefore` | `string \| null` | Runner version at sandbox start |
|
|
43
|
+
| `versions.runnerAfter` | `string \| null` | Runner version after auto-update |
|
|
44
|
+
| `versions.runnerWasUpdated` | `boolean` | Whether the runner was auto-updated during provisioning |
|
|
45
|
+
|
|
46
|
+
### `test`
|
|
47
|
+
|
|
48
|
+
| Field | Type | Description |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `test.file` | `string \| null` | Relative path to the test file |
|
|
51
|
+
| `test.name` | `string \| null` | Name of the test case |
|
|
52
|
+
| `test.suite` | `string \| null` | Name of the parent `describe` block |
|
|
53
|
+
| `test.passed` | `boolean` | Whether the test passed |
|
|
54
|
+
| `test.caseId` | `string \| null` | Database ID for this test case |
|
|
55
|
+
| `test.runId` | `string \| null` | Database ID for the overall test run |
|
|
56
|
+
| `test.error` | `string \| null` | Error message if the test failed |
|
|
57
|
+
| `test.errorStack` | `string \| null` | Error stack trace if the test failed |
|
|
58
|
+
|
|
59
|
+
### `urls`
|
|
60
|
+
|
|
61
|
+
| Field | Type | Description |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `urls.api` | `string \| null` | API root URL used for this test |
|
|
64
|
+
| `urls.console` | `string \| null` | TestDriver console base URL |
|
|
65
|
+
| `urls.vnc` | `string \| null` | VNC URL for the sandbox |
|
|
66
|
+
| `urls.testRun` | `string \| null` | Direct link to this test case in the console |
|
|
67
|
+
|
|
68
|
+
### `replay`
|
|
69
|
+
|
|
70
|
+
The `replay` object contains the recording replay URL and derived embed links. The `gifUrl` and `embedUrl` are generated automatically from the replay URL.
|
|
71
|
+
|
|
72
|
+
| Field | Type | Description |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `replay.url` | `string \| null` | Recording replay URL |
|
|
75
|
+
| `replay.gifUrl` | `string \| null` | Animated GIF thumbnail of the recording |
|
|
76
|
+
| `replay.embedUrl` | `string \| null` | Embeddable replay URL (appends `&embed=true`) |
|
|
77
|
+
| `replay.markdown` | `string \| null` | Ready-to-use Markdown embed with GIF linking to the replay |
|
|
78
|
+
|
|
79
|
+
The `replay.markdown` field produces a clickable GIF badge you can paste directly into PR comments, README files, or issue descriptions:
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
[](https://console.testdriver.ai/replay/abc123?share=xyz)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### `date`
|
|
86
|
+
|
|
87
|
+
| Field | Type | Description |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `date` | `string` | ISO 8601 timestamp when the test finished |
|
|
90
|
+
|
|
91
|
+
### `team`
|
|
92
|
+
|
|
93
|
+
| Field | Type | Description |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `team.id` | `string \| null` | Team ID from the sandbox |
|
|
96
|
+
| `team.sessionId` | `string \| null` | SDK session ID |
|
|
97
|
+
|
|
98
|
+
### `infrastructure`
|
|
99
|
+
|
|
100
|
+
| Field | Type | Description |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `infrastructure.sandboxId` | `string \| null` | Sandbox instance ID |
|
|
103
|
+
| `infrastructure.instanceId` | `string \| null` | Instance ID |
|
|
104
|
+
| `infrastructure.os` | `string \| null` | Operating system of the sandbox (`"linux"` or `"windows"`) |
|
|
105
|
+
| `infrastructure.amiId` | `string \| null` | AWS AMI ID used for provisioning |
|
|
106
|
+
| `infrastructure.e2bTemplateId` | `string \| null` | E2B template ID used for provisioning |
|
|
107
|
+
| `infrastructure.imageVersion` | `string \| null` | Sandbox image version |
|
|
108
|
+
|
|
109
|
+
### `realtime`
|
|
110
|
+
|
|
111
|
+
| Field | Type | Description |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `realtime.channel` | `string \| null` | Ably channel name used for communication |
|
|
114
|
+
| `realtime.messageCount` | `number` | Number of messages published to the realtime channel |
|
|
115
|
+
|
|
116
|
+
### `interactions`
|
|
117
|
+
|
|
118
|
+
| Field | Type | Description |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| `interactions.total` | `number` | Total number of interactions recorded |
|
|
121
|
+
| `interactions.cached` | `number` | Number of interactions served from cache |
|
|
122
|
+
| `interactions.byType` | `object` | Breakdown of interactions by type (e.g. `find`, `click`, `assert`) |
|
|
123
|
+
|
|
124
|
+
## Example Output
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"sdkVersion": "7.8.0",
|
|
129
|
+
"vitestVersion": "4.0.0",
|
|
130
|
+
"apiVersion": "1.45.0",
|
|
131
|
+
"runnerVersionBefore": "2.1.0",
|
|
132
|
+
"runnerVersionAfter": "2.1.1",
|
|
133
|
+
"wasUpdated": true,
|
|
134
|
+
"apiUrl": "https://api.testdriver.ai",
|
|
135
|
+
"consoleUrl": "https://console.testdriver.ai",
|
|
136
|
+
"testRunLink": "https://console.testdriver.ai/runs/abc123/def456",
|
|
137
|
+
"dashcamUrl": "https://app.dashcam.io/replay/abc123",
|
|
138
|
+
"vncUrl": "wss://sandbox-123.testdriver.ai/vnc",
|
|
139
|
+
"date": "2025-01-15T14:30:00.000Z",
|
|
140
|
+
"team": {
|
|
141
|
+
"id": "team_abc123",
|
|
142
|
+
"sessionId": "sess_xyz789"
|
|
143
|
+
},
|
|
144
|
+
"infrastructure": {
|
|
145
|
+
"sandboxId": "sandbox-123",
|
|
146
|
+
"instanceId": "i-abc123",
|
|
147
|
+
"os": "linux",
|
|
148
|
+
"amiId": "ami-0abc123",
|
|
149
|
+
"e2bTemplateId": null,
|
|
150
|
+
"imageVersion": "v2.1.0"
|
|
151
|
+
},
|
|
152
|
+
"realtime": {
|
|
153
|
+
"channel": "sandbox:sandbox-123",
|
|
154
|
+
"messageCount": 42
|
|
155
|
+
},
|
|
156
|
+
"interactions": {
|
|
157
|
+
"total": 15,
|
|
158
|
+
"cached": 3,
|
|
159
|
+
"byType": {
|
|
160
|
+
"find": 8,
|
|
161
|
+
"click": 5,
|
|
162
|
+
"assert": 2
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Using Result Files in CI
|
|
169
|
+
|
|
170
|
+
Result files are useful for extracting test metadata in CI pipelines without parsing log output.
|
|
171
|
+
|
|
172
|
+
### GitHub Actions Example
|
|
173
|
+
|
|
174
|
+
Use `fromJSON` to parse a result file into a GitHub Actions expression you can reference in subsequent steps:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
- name: Run tests
|
|
178
|
+
run: npx vitest run tests/login.test.mjs
|
|
179
|
+
|
|
180
|
+
- name: Parse result
|
|
181
|
+
id: result
|
|
182
|
+
run: |
|
|
183
|
+
# Read the first JSON result file
|
|
184
|
+
FILE=$(find .testdriver/results -name '*.json' | head -n 1)
|
|
185
|
+
echo "json=$(cat "$FILE")" >> "$GITHUB_OUTPUT"
|
|
186
|
+
|
|
187
|
+
- name: Comment on PR
|
|
188
|
+
if: fromJSON(steps.result.outputs.json).test.passed == false
|
|
189
|
+
uses: actions/github-script@v7
|
|
190
|
+
with:
|
|
191
|
+
script: |
|
|
192
|
+
const result = ${{ steps.result.outputs.json }};
|
|
193
|
+
await github.rest.issues.createComment({
|
|
194
|
+
owner: context.repo.owner,
|
|
195
|
+
repo: context.repo.repo,
|
|
196
|
+
issue_number: context.issue.number,
|
|
197
|
+
body: [
|
|
198
|
+
`❌ **${result.test.name}** failed`,
|
|
199
|
+
``,
|
|
200
|
+
`Error: ${result.test.error}`,
|
|
201
|
+
``,
|
|
202
|
+
result.replay.markdown,
|
|
203
|
+
``,
|
|
204
|
+
`[View full recording](${result.urls.testRun})`
|
|
205
|
+
].join('\n')
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
You can also load all results into a matrix or iterate over them:
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
- name: Run tests
|
|
213
|
+
run: npx vitest run tests/*.test.mjs
|
|
214
|
+
|
|
215
|
+
- name: Collect results
|
|
216
|
+
id: results
|
|
217
|
+
run: |
|
|
218
|
+
# Merge all result files into a JSON array
|
|
219
|
+
echo "json=$(find .testdriver/results -name '*.json' -exec cat {} + | jq -s '.')" >> "$GITHUB_OUTPUT"
|
|
220
|
+
|
|
221
|
+
- name: Summary
|
|
222
|
+
run: |
|
|
223
|
+
echo '## Test Results' >> $GITHUB_STEP_SUMMARY
|
|
224
|
+
RESULTS='${{ steps.results.outputs.json }}'
|
|
225
|
+
echo "$RESULTS" | jq -r '.[] | "| \(.test.name) | \(if .test.passed then "✅" else "❌" end) | \(.urls.testRun) |"' >> $GITHUB_STEP_SUMMARY
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Reading Results Programmatically
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
import fs from "fs";
|
|
232
|
+
import path from "path";
|
|
233
|
+
|
|
234
|
+
const resultsDir = ".testdriver/results";
|
|
235
|
+
|
|
236
|
+
function readResults(dir) {
|
|
237
|
+
const results = [];
|
|
238
|
+
for (const testDir of fs.readdirSync(dir, { recursive: true })) {
|
|
239
|
+
const fullPath = path.join(dir, testDir);
|
|
240
|
+
if (fullPath.endsWith(".json") && fs.statSync(fullPath).isFile()) {
|
|
241
|
+
results.push(JSON.parse(fs.readFileSync(fullPath, "utf-8")));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return results;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const results = readResults(resultsDir);
|
|
248
|
+
const passed = results.filter(r => r.test.passed);
|
|
249
|
+
const failed = results.filter(r => !r.test.passed);
|
|
250
|
+
|
|
251
|
+
console.log(`${passed.length} passed, ${failed.length} failed`);
|
|
252
|
+
for (const r of failed) {
|
|
253
|
+
console.log(` FAIL: ${r.test.name} — ${r.test.error}`);
|
|
254
|
+
console.log(` Recording: ${r.urls.testRun}`);
|
|
255
|
+
console.log(` Embed: ${r.replay.markdown}`);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
@@ -297,8 +297,9 @@ function updateExistingMDX(existingContent, filename, testcaseId) {
|
|
|
297
297
|
const replayUrl = generateReplayUrl(testcaseId);
|
|
298
298
|
|
|
299
299
|
// Pattern to match the marker followed by the iframe tag
|
|
300
|
+
const escapedFilename = filename.replace(/\./g, '\\.');
|
|
300
301
|
const pattern = new RegExp(
|
|
301
|
-
`(\\{/\\* ${
|
|
302
|
+
`(\\{/\\* ${escapedFilename} output \\*/\\}\\s*)<iframe[^>]*src="[^"]*"([^]*?)/>`,
|
|
302
303
|
's'
|
|
303
304
|
);
|
|
304
305
|
|
|
@@ -312,6 +313,25 @@ function updateExistingMDX(existingContent, filename, testcaseId) {
|
|
|
312
313
|
return updated;
|
|
313
314
|
}
|
|
314
315
|
|
|
316
|
+
// Update the source code block in an existing MDX file with fresh content from the test file
|
|
317
|
+
function updateSourceCodeBlock(existingContent, testMeta) {
|
|
318
|
+
const escapedFilename = testMeta.filename.replace(/\./g, '\\.');
|
|
319
|
+
const codeBlockPattern = new RegExp(
|
|
320
|
+
'(```javascript\\s+title="' + escapedFilename + '"[^\\n]*\\n)[\\s\\S]*?(\\n```)',
|
|
321
|
+
''
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
const match = existingContent.match(codeBlockPattern);
|
|
325
|
+
if (!match) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return existingContent.replace(
|
|
330
|
+
codeBlockPattern,
|
|
331
|
+
`$1${testMeta.content.trim()}$2`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
315
335
|
// Generate MDX content
|
|
316
336
|
function generateMDX(testMeta, manifest, description) {
|
|
317
337
|
const slug = generateSlug(testMeta.filename);
|
|
@@ -399,13 +419,29 @@ function updateDocsNavigation(docsJson, examplePages, options) {
|
|
|
399
419
|
return false;
|
|
400
420
|
}
|
|
401
421
|
|
|
402
|
-
// Find
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
422
|
+
// Find Examples group - it may be nested inside Overview's pages
|
|
423
|
+
const examplesPages = examplePages.map((slug) => `/v7/examples/${slug}`);
|
|
424
|
+
let examplesGroup = null;
|
|
425
|
+
|
|
426
|
+
// Search top-level groups first
|
|
427
|
+
examplesGroup = v7Version.groups.find((g) =>
|
|
428
|
+
typeof g === "object" && g.group === "Examples"
|
|
406
429
|
);
|
|
407
430
|
|
|
408
|
-
|
|
431
|
+
// If not found at top level, search inside each group's pages (nested groups)
|
|
432
|
+
if (!examplesGroup) {
|
|
433
|
+
for (const group of v7Version.groups) {
|
|
434
|
+
if (group.pages) {
|
|
435
|
+
const nested = group.pages.find((p) =>
|
|
436
|
+
typeof p === "object" && p.group === "Examples"
|
|
437
|
+
);
|
|
438
|
+
if (nested) {
|
|
439
|
+
examplesGroup = nested;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
409
445
|
|
|
410
446
|
if (examplesGroup) {
|
|
411
447
|
// Update existing group
|
|
@@ -414,20 +450,22 @@ function updateDocsNavigation(docsJson, examplePages, options) {
|
|
|
414
450
|
console.log("🔄 Updated existing Examples group in navigation");
|
|
415
451
|
}
|
|
416
452
|
} else {
|
|
417
|
-
// Create new group
|
|
418
|
-
const
|
|
453
|
+
// Create new group nested inside Overview
|
|
454
|
+
const overviewGroup = v7Version.groups.find((g) => g.group === "Overview");
|
|
419
455
|
const newGroup = {
|
|
420
456
|
group: "Examples",
|
|
421
457
|
icon: "code",
|
|
422
458
|
pages: examplesPages,
|
|
423
459
|
};
|
|
424
|
-
|
|
425
|
-
if (
|
|
426
|
-
|
|
460
|
+
|
|
461
|
+
if (overviewGroup && overviewGroup.pages) {
|
|
462
|
+
// Insert after the second page in Overview (after what-is-testdriver)
|
|
463
|
+
const insertIdx = Math.min(2, overviewGroup.pages.length);
|
|
464
|
+
overviewGroup.pages.splice(insertIdx, 0, newGroup);
|
|
427
465
|
} else {
|
|
428
466
|
v7Version.groups.push(newGroup);
|
|
429
467
|
}
|
|
430
|
-
|
|
468
|
+
|
|
431
469
|
if (options.verbose) {
|
|
432
470
|
console.log("➕ Added new Examples group to navigation");
|
|
433
471
|
}
|
|
@@ -439,7 +477,7 @@ function updateDocsNavigation(docsJson, examplePages, options) {
|
|
|
439
477
|
// Show help
|
|
440
478
|
function showHelp() {
|
|
441
479
|
console.log(`
|
|
442
|
-
Update Example Docs
|
|
480
|
+
Update Example Docs from Test Files
|
|
443
481
|
|
|
444
482
|
Usage:
|
|
445
483
|
node generate-examples.js [options]
|
|
@@ -453,12 +491,16 @@ Environment Variables:
|
|
|
453
491
|
TD_API_ROOT API root URL (default: https://api.testdriver.ai)
|
|
454
492
|
|
|
455
493
|
Description:
|
|
456
|
-
Reads
|
|
457
|
-
|
|
494
|
+
Reads example test files and updates/generates MDX documentation pages.
|
|
495
|
+
|
|
496
|
+
For existing MDX files:
|
|
497
|
+
- Updates the source code block from the test file
|
|
498
|
+
- Updates the iframe src URL from examples-manifest.json
|
|
499
|
+
|
|
500
|
+
For new test files without an MDX page:
|
|
501
|
+
- Generates a new MDX documentation page
|
|
458
502
|
|
|
459
|
-
|
|
460
|
-
The iframe following the marker will have its src updated to the
|
|
461
|
-
API replay endpoint.
|
|
503
|
+
Also updates the docs.json navigation with the current example pages.
|
|
462
504
|
`);
|
|
463
505
|
}
|
|
464
506
|
|
|
@@ -471,7 +513,7 @@ async function main() {
|
|
|
471
513
|
process.exit(0);
|
|
472
514
|
}
|
|
473
515
|
|
|
474
|
-
console.log("🚀 Updating example documentation
|
|
516
|
+
console.log("🚀 Updating example documentation...\n");
|
|
475
517
|
|
|
476
518
|
if (options.dryRun) {
|
|
477
519
|
console.log("📋 DRY RUN - no files will be written\n");
|
|
@@ -480,67 +522,92 @@ async function main() {
|
|
|
480
522
|
// Load manifest
|
|
481
523
|
const manifest = loadManifest();
|
|
482
524
|
|
|
483
|
-
// Get
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
: [];
|
|
525
|
+
// Get all test files
|
|
526
|
+
const testFiles = getExampleFiles();
|
|
527
|
+
console.log(`📂 Found ${testFiles.length} example test files\n`);
|
|
487
528
|
|
|
488
|
-
|
|
529
|
+
// Ensure output dir exists
|
|
530
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
531
|
+
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
532
|
+
}
|
|
489
533
|
|
|
490
534
|
let updated = 0;
|
|
535
|
+
let created = 0;
|
|
491
536
|
let skipped = 0;
|
|
492
537
|
let errors = 0;
|
|
538
|
+
const exampleSlugs = [];
|
|
539
|
+
|
|
540
|
+
for (const file of testFiles) {
|
|
541
|
+
const filePath = path.join(EXAMPLES_DIR, file);
|
|
542
|
+
const testMeta = parseTestFile(filePath);
|
|
543
|
+
const slug = generateSlug(testMeta.filename);
|
|
544
|
+
exampleSlugs.push(slug);
|
|
493
545
|
|
|
494
|
-
|
|
495
|
-
const outputPath = path.join(OUTPUT_DIR, mdxFile);
|
|
546
|
+
const outputPath = path.join(OUTPUT_DIR, `${slug}.mdx`);
|
|
496
547
|
|
|
497
548
|
try {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (
|
|
506
|
-
|
|
549
|
+
if (fs.existsSync(outputPath)) {
|
|
550
|
+
// Update existing MDX file
|
|
551
|
+
let content = fs.readFileSync(outputPath, 'utf-8');
|
|
552
|
+
let changed = false;
|
|
553
|
+
|
|
554
|
+
// Update source code block from the test file
|
|
555
|
+
const sourceUpdated = updateSourceCodeBlock(content, testMeta);
|
|
556
|
+
if (sourceUpdated && sourceUpdated !== content) {
|
|
557
|
+
content = sourceUpdated;
|
|
558
|
+
changed = true;
|
|
507
559
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
console.log(`⏭️ ${mdxFile} (no URL in manifest for ${testFilename})`);
|
|
560
|
+
|
|
561
|
+
// Update iframe URL if manifest entry exists
|
|
562
|
+
const manifestEntry = manifest.examples[testMeta.filename];
|
|
563
|
+
const testcaseId = manifestEntry?.url ? extractTestcaseId(manifestEntry.url) : null;
|
|
564
|
+
if (testcaseId) {
|
|
565
|
+
const iframeUpdated = updateExistingMDX(content, testMeta.filename, testcaseId);
|
|
566
|
+
if (iframeUpdated && iframeUpdated !== content) {
|
|
567
|
+
content = iframeUpdated;
|
|
568
|
+
changed = true;
|
|
569
|
+
}
|
|
519
570
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
571
|
+
|
|
572
|
+
if (changed) {
|
|
573
|
+
if (!options.dryRun) {
|
|
574
|
+
fs.writeFileSync(outputPath, content, 'utf-8');
|
|
575
|
+
}
|
|
576
|
+
updated++;
|
|
577
|
+
console.log(`🔄 ${slug}.mdx (updated)`);
|
|
578
|
+
} else {
|
|
579
|
+
skipped++;
|
|
580
|
+
if (options.verbose) {
|
|
581
|
+
console.log(`⏭️ ${slug}.mdx (unchanged)`);
|
|
582
|
+
}
|
|
528
583
|
}
|
|
529
|
-
updated++;
|
|
530
|
-
console.log(`🔄 ${mdxFile} (updated iframe)`);
|
|
531
584
|
} else {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
585
|
+
// Generate new MDX file
|
|
586
|
+
const description = generateFallbackDescription(testMeta);
|
|
587
|
+
const mdx = generateMDX(testMeta, manifest, description);
|
|
588
|
+
if (!options.dryRun) {
|
|
589
|
+
fs.writeFileSync(outputPath, mdx, 'utf-8');
|
|
535
590
|
}
|
|
591
|
+
created++;
|
|
592
|
+
console.log(`✨ ${slug}.mdx (created)`);
|
|
536
593
|
}
|
|
537
594
|
} catch (error) {
|
|
538
|
-
console.error(`❌ ${
|
|
595
|
+
console.error(`❌ ${file}: ${error.message}`);
|
|
539
596
|
errors++;
|
|
540
597
|
}
|
|
541
598
|
}
|
|
542
599
|
|
|
600
|
+
// Update docs.json navigation
|
|
601
|
+
if (!options.dryRun) {
|
|
602
|
+
const docsJson = loadDocsJson();
|
|
603
|
+
if (updateDocsNavigation(docsJson, exampleSlugs, options)) {
|
|
604
|
+
saveDocsJson(docsJson);
|
|
605
|
+
console.log("\n📝 Updated docs.json navigation");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
543
609
|
console.log(`\n✨ Complete!`);
|
|
610
|
+
console.log(` Created: ${created} new docs`);
|
|
544
611
|
console.log(` Updated: ${updated} docs`);
|
|
545
612
|
console.log(` Skipped: ${skipped} unchanged`);
|
|
546
613
|
if (errors > 0) {
|
package/docs/docs.json
CHANGED
|
@@ -27,28 +27,29 @@
|
|
|
27
27
|
"pages": [
|
|
28
28
|
"/v7/examples/ai",
|
|
29
29
|
"/v7/examples/assert",
|
|
30
|
-
"/v7/examples/captcha-api",
|
|
31
30
|
"/v7/examples/chrome-extension",
|
|
32
|
-
"/v7/examples/drag-and-drop",
|
|
33
31
|
"/v7/examples/element-not-found",
|
|
34
32
|
"/v7/examples/exec-output",
|
|
35
33
|
"/v7/examples/exec-pwsh",
|
|
34
|
+
"/v7/examples/findall-coffee-icons",
|
|
36
35
|
"/v7/examples/focus-window",
|
|
36
|
+
"/v7/examples/formatted-logging",
|
|
37
37
|
"/v7/examples/hover-image",
|
|
38
|
+
"/v7/examples/hover-text-with-description",
|
|
38
39
|
"/v7/examples/hover-text",
|
|
39
40
|
"/v7/examples/installer",
|
|
40
41
|
"/v7/examples/launch-vscode-linux",
|
|
41
42
|
"/v7/examples/match-image",
|
|
43
|
+
"/v7/examples/parse",
|
|
42
44
|
"/v7/examples/press-keys",
|
|
45
|
+
"/v7/examples/prompt",
|
|
43
46
|
"/v7/examples/scroll-keyboard",
|
|
44
47
|
"/v7/examples/scroll-until-image",
|
|
45
|
-
"/v7/examples/scroll-until-text",
|
|
46
48
|
"/v7/examples/scroll",
|
|
47
49
|
"/v7/examples/type",
|
|
48
50
|
"/v7/examples/windows-installer"
|
|
49
51
|
]
|
|
50
52
|
},
|
|
51
|
-
|
|
52
53
|
{
|
|
53
54
|
"group": "Deployment",
|
|
54
55
|
"icon": "server",
|
|
@@ -60,7 +61,6 @@
|
|
|
60
61
|
"/changelog"
|
|
61
62
|
]
|
|
62
63
|
},
|
|
63
|
-
|
|
64
64
|
{
|
|
65
65
|
"group": "GitHub Copilot",
|
|
66
66
|
"pages": [
|
|
@@ -106,34 +106,33 @@
|
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
|
+
{
|
|
110
|
+
"group": "Actions",
|
|
111
|
+
"pages": [
|
|
112
|
+
"/v7/ai",
|
|
113
|
+
"/v7/assert",
|
|
114
|
+
"/v7/captcha",
|
|
115
|
+
"/v7/click",
|
|
116
|
+
"/v7/double-click",
|
|
117
|
+
"/v7/exec",
|
|
118
|
+
"/v7/find",
|
|
119
|
+
"/v7/focus-application",
|
|
120
|
+
"/v7/hover",
|
|
121
|
+
"/v7/mouse-down",
|
|
122
|
+
"/v7/mouse-up",
|
|
123
|
+
"/v7/parse",
|
|
124
|
+
"/v7/press-keys",
|
|
125
|
+
"/v7/right-click",
|
|
126
|
+
"/v7/screenshot",
|
|
127
|
+
"/v7/scroll",
|
|
128
|
+
"/v7/type"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
109
131
|
{
|
|
110
132
|
"group": "SDK Reference",
|
|
111
133
|
"pages": [
|
|
112
134
|
"/v7/client",
|
|
113
135
|
"/v7/elements",
|
|
114
|
-
{
|
|
115
|
-
"group": "Actions",
|
|
116
|
-
"icon": "bolt",
|
|
117
|
-
"pages": [
|
|
118
|
-
"/v7/ai",
|
|
119
|
-
"/v7/assert",
|
|
120
|
-
"/v7/captcha",
|
|
121
|
-
"/v7/click",
|
|
122
|
-
"/v7/double-click",
|
|
123
|
-
"/v7/exec",
|
|
124
|
-
"/v7/find",
|
|
125
|
-
"/v7/focus-application",
|
|
126
|
-
"/v7/hover",
|
|
127
|
-
"/v7/mouse-down",
|
|
128
|
-
"/v7/mouse-up",
|
|
129
|
-
"/v7/parse",
|
|
130
|
-
"/v7/press-keys",
|
|
131
|
-
"/v7/right-click",
|
|
132
|
-
"/v7/screenshot",
|
|
133
|
-
"/v7/scroll",
|
|
134
|
-
"/v7/type"
|
|
135
|
-
]
|
|
136
|
-
},
|
|
137
136
|
"/v7/dashcam"
|
|
138
137
|
]
|
|
139
138
|
}
|
package/docs/v7/examples/ai.mdx
CHANGED
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* ai.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api
|
|
15
|
+
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d04ac2e6e94933886778/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -23,7 +23,8 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="ai.test.mjs" {17}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - AI Test
|
|
26
|
+
* TestDriver SDK - AI Test (Vitest)
|
|
27
|
+
* Tests the AI exploratory loop (ai) functionality
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
import { describe, expect, it } from "vitest";
|
|
@@ -31,7 +32,7 @@ import { TestDriver } from "testdriverai/vitest/hooks";
|
|
|
31
32
|
|
|
32
33
|
describe("AI Test", () => {
|
|
33
34
|
it("should use ai to search for testdriver on Google", async (context) => {
|
|
34
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP
|
|
35
|
+
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
|
|
35
36
|
|
|
36
37
|
// provision.chrome() automatically calls ready() and starts dashcam
|
|
37
38
|
await testdriver.provision.chrome({
|