testdriverai 7.8.0 → 7.9.0-test.1

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 (55) hide show
  1. package/agent/index.js +12 -0
  2. package/agent/lib/http.js +21 -3
  3. package/agent/lib/logger.js +15 -0
  4. package/agent/lib/provision-commands.js +176 -0
  5. package/agent/lib/sandbox.js +667 -118
  6. package/agent/lib/sdk.js +1 -20
  7. package/ai/skills/testdriver-find/SKILL.md +14 -20
  8. package/docs/_data/examples-manifest.json +46 -46
  9. package/docs/_scripts/extract-example-urls.js +67 -72
  10. package/docs/docs.json +2 -1
  11. package/docs/v7/examples/ai.mdx +1 -1
  12. package/docs/v7/examples/assert.mdx +1 -1
  13. package/docs/v7/examples/captcha-api.mdx +1 -1
  14. package/docs/v7/examples/chrome-extension.mdx +1 -1
  15. package/docs/v7/examples/drag-and-drop.mdx +1 -1
  16. package/docs/v7/examples/element-not-found.mdx +1 -1
  17. package/docs/v7/examples/exec-output.mdx +1 -1
  18. package/docs/v7/examples/exec-pwsh.mdx +1 -1
  19. package/docs/v7/examples/focus-window.mdx +1 -1
  20. package/docs/v7/examples/hover-image.mdx +1 -1
  21. package/docs/v7/examples/hover-text.mdx +1 -1
  22. package/docs/v7/examples/installer.mdx +1 -1
  23. package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
  24. package/docs/v7/examples/match-image.mdx +1 -1
  25. package/docs/v7/examples/press-keys.mdx +1 -1
  26. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  27. package/docs/v7/examples/scroll-until-image.mdx +1 -1
  28. package/docs/v7/examples/scroll-until-text.mdx +1 -1
  29. package/docs/v7/examples/scroll.mdx +1 -1
  30. package/docs/v7/examples/type.mdx +1 -1
  31. package/docs/v7/examples/windows-installer.mdx +1 -1
  32. package/docs/v7/find.mdx +14 -20
  33. package/docs/v7/test-results-json.mdx +258 -0
  34. package/examples/scroll-keyboard.test.mjs +1 -1
  35. package/examples/scroll.test.mjs +1 -12
  36. package/interfaces/vitest-plugin.mjs +167 -51
  37. package/lib/core/Dashcam.js +16 -22
  38. package/lib/environments.json +8 -4
  39. package/lib/github-comment.mjs +58 -40
  40. package/lib/init-project.js +5 -67
  41. package/lib/resolve-channel.js +39 -10
  42. package/lib/sentry.js +47 -23
  43. package/lib/vitest/hooks.mjs +117 -20
  44. package/manual/exec-stream-logs.test.mjs +25 -0
  45. package/mcp-server/dist/server.mjs +28 -8
  46. package/mcp-server/src/server.ts +31 -8
  47. package/package.json +2 -1
  48. package/sdk.d.ts +4 -0
  49. package/sdk.js +42 -12
  50. package/setup/aws/install-dev-runner.sh +79 -0
  51. package/setup/aws/spawn-runner.sh +165 -0
  52. package/test-sentry-span.js +35 -0
  53. package/vitest.config.mjs +7 -3
  54. package/vitest.runner.config.mjs +33 -0
  55. package/docs/v7/_drafts/core.mdx +0 -458
package/agent/lib/sdk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { events } = require("../events");
2
- const crypto = require("crypto");
2
+ const { getSentryTraceHeaders } = require("./http");
3
3
 
4
4
  // get the version from package.json
5
5
  const { version } = require("../../package.json");
@@ -114,25 +114,6 @@ async function withRetry(fn, options = {}) {
114
114
  throw lastError;
115
115
  }
116
116
 
117
- /**
118
- * Generate Sentry trace headers for distributed tracing
119
- * Uses the same trace ID derivation as the API (MD5 hash of session ID)
120
- * @param {string} sessionId - The session ID
121
- * @returns {Object} Headers object with sentry-trace and baggage
122
- */
123
- function getSentryTraceHeaders(sessionId) {
124
- if (!sessionId) return {};
125
-
126
- // Same logic as API: derive trace ID from session ID
127
- const traceId = crypto.createHash('md5').update(sessionId).digest('hex');
128
- const spanId = crypto.randomBytes(8).toString('hex');
129
-
130
- return {
131
- 'sentry-trace': `${traceId}-${spanId}-1`,
132
- 'baggage': `sentry-trace_id=${traceId},sentry-sample_rate=1.0,sentry-sampled=true`
133
- };
134
- }
135
-
136
117
  // Factory function that creates SDK with the provided emitter, config, and session
137
118
  let token = null;
138
119
  const createSDK = (emitter, config, sessionInstance) => {
@@ -49,8 +49,8 @@ const element = await testdriver.find(description, options)
49
49
  - `"any"` — No wrapping, uses the description as-is (default behavior)
50
50
  </ParamField>
51
51
 
52
- <ParamField path="zoom" type="boolean" default={false}>
53
- Enable two-phase zoom mode for better precision in crowded UIs with many similar elements.
52
+ <ParamField path="zoom" type="boolean" default={true}>
53
+ Two-phase zoom mode for better precision in crowded UIs with many similar elements. Enabled by default.
54
54
  </ParamField>
55
55
 
56
56
  <ParamField path="ai" type="object">
@@ -332,14 +332,19 @@ The `timeout` option:
332
332
  - Returns the element (check `element.found()` if not throwing on failure)
333
333
  - Set to `0` to disable polling and make a single attempt
334
334
 
335
- ## Zoom Mode for Crowded UIs
335
+ ## Zoom Mode
336
336
 
337
- When dealing with many similar icons or elements clustered together (like browser toolbars), enable `zoom` mode for better precision:
337
+ Zoom mode is **enabled by default**. It uses a two-phase approach for better precision when locating elements, especially in crowded UIs with many similar elements.
338
+
339
+ To disable zoom for a specific find call, pass `zoom: false`:
338
340
 
339
341
  ```javascript
340
- // Enable zoom for better precision in crowded UIs
341
- const extensionsBtn = await testdriver.find('extensions puzzle icon in Chrome toolbar', { zoom: true });
342
+ // Zoom is on by default no option needed
343
+ const extensionsBtn = await testdriver.find('extensions puzzle icon in Chrome toolbar');
342
344
  await extensionsBtn.click();
345
+
346
+ // Disable zoom for a specific call if needed
347
+ const largeButton = await testdriver.find('big hero button', { zoom: false });
343
348
  ```
344
349
 
345
350
  ### How Zoom Mode Works
@@ -352,22 +357,11 @@ await extensionsBtn.click();
352
357
  This two-phase approach gives the AI a higher-resolution view of the target area, improving accuracy when multiple similar elements are close together.
353
358
 
354
359
  <Tip>
355
- Use `zoom: true` when:
356
- - Clicking small icons in toolbars
357
- - Selecting from a grid of similar items
358
- - Targeting elements in dense UI areas
359
- - The default locate is clicking the wrong similar element
360
- - You get an AI verification rejection like "The crosshair is located in the empty space of the browser's tab bar/title bar area" — this means the initial locate was imprecise and zoom will help the AI pinpoint the correct element
360
+ You may want to disable zoom with `zoom: false` when:
361
+ - Targeting large, isolated elements where the extra precision isn't needed
362
+ - You want to speed up find calls in simple UIs
361
363
  </Tip>
362
364
 
363
- ```javascript
364
- // Without zoom - may click wrong icon in toolbar
365
- const icon = await testdriver.find('settings icon');
366
-
367
- // With zoom - better precision for crowded areas
368
- const icon = await testdriver.find('settings icon', { zoom: true });
369
- ```
370
-
371
365
  ## Cache Options
372
366
 
373
367
  Control caching behavior to optimize performance, especially when using dynamic variables in prompts.
@@ -2,104 +2,104 @@
2
2
  "$schema": "./examples-manifest.schema.json",
3
3
  "examples": {
4
4
  "assert.test.mjs": {
5
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b6206a177a05bccd1cc",
6
- "lastUpdated": "2026-03-03T00:32:25.279Z"
5
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec55d526a093f1e6c99",
6
+ "lastUpdated": "2026-03-26T00:45:20.791Z"
7
7
  },
8
8
  "drag-and-drop.test.mjs": {
9
9
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42fc0ac3cc632a918b",
10
10
  "lastUpdated": "2026-03-03T00:32:25.275Z"
11
11
  },
12
12
  "exec-pwsh.test.mjs": {
13
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42565d339e8065f180",
14
- "lastUpdated": "2026-03-03T00:32:25.275Z"
13
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eb36ebfe4f295e7800a",
14
+ "lastUpdated": "2026-03-26T00:34:06.947Z"
15
15
  },
16
16
  "match-image.test.mjs": {
17
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42258e8885264fc704",
18
- "lastUpdated": "2026-03-03T00:32:25.275Z"
17
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eb56f887c881af8c66b",
18
+ "lastUpdated": "2026-03-26T00:34:08.349Z"
19
19
  },
20
20
  "scroll-until-text.test.mjs": {
21
21
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b99dc33133fc0da9440",
22
22
  "lastUpdated": "2026-03-03T00:32:25.282Z"
23
23
  },
24
24
  "hover-text-with-description.test.mjs": {
25
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b820d4a5265e44e7d89",
26
- "lastUpdated": "2026-03-03T00:32:25.282Z"
25
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eb65d526a093f1e6c89",
26
+ "lastUpdated": "2026-03-26T00:32:54.875Z"
27
27
  },
28
28
  "windows-installer.test.mjs": {
29
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42565d339e8065f17f",
30
- "lastUpdated": "2026-03-03T00:32:25.275Z"
29
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eba6ebfe4f295e78011",
30
+ "lastUpdated": "2026-03-26T00:34:13.507Z"
31
31
  },
32
32
  "exec-output.test.mjs": {
33
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42fc0ac3cc632a918c",
34
- "lastUpdated": "2026-03-03T00:32:25.275Z"
33
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ebc5d526a093f1e6c8d",
34
+ "lastUpdated": "2026-03-26T00:34:14.964Z"
35
35
  },
36
36
  "chrome-extension.test.mjs": {
37
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b91fc0ac3cc632a91a0",
38
- "lastUpdated": "2026-03-03T00:32:25.282Z"
37
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eb16ebfe4f295e78008",
38
+ "lastUpdated": "2026-03-26T00:33:28.632Z"
39
39
  },
40
40
  "launch-vscode-linux.test.mjs": {
41
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b91113035da665496a6",
42
- "lastUpdated": "2026-03-03T00:32:25.282Z"
41
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47eb85d526a093f1e6c8c",
42
+ "lastUpdated": "2026-03-26T00:38:10.516Z"
43
43
  },
44
44
  "hover-image.test.mjs": {
45
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b77fc0ac3cc632a9198",
46
- "lastUpdated": "2026-03-03T00:32:25.279Z"
45
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ebebada9b8191b2daf7",
46
+ "lastUpdated": "2026-03-26T00:33:39.385Z"
47
47
  },
48
48
  "installer.test.mjs": {
49
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b570446888b52a4e1c9",
50
- "lastUpdated": "2026-03-03T00:32:25.277Z"
49
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec06f887c881af8c673",
50
+ "lastUpdated": "2026-03-26T00:33:04.023Z"
51
51
  },
52
52
  "type.test.mjs": {
53
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b8d49845ced0b71e2bf",
54
- "lastUpdated": "2026-03-03T00:32:25.282Z"
53
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec25d526a093f1e6c92",
54
+ "lastUpdated": "2026-03-26T00:33:43.124Z"
55
55
  },
56
56
  "press-keys.test.mjs": {
57
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b800d4a5265e44e7d86",
58
- "lastUpdated": "2026-03-03T00:32:25.281Z"
57
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec3d5e55524a4d6ca04",
58
+ "lastUpdated": "2026-03-26T00:44:36.564Z"
59
59
  },
60
60
  "scroll-keyboard.test.mjs": {
61
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b82258e8885264fc728",
62
- "lastUpdated": "2026-03-03T00:32:25.281Z"
61
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec85d526a093f1e6c9b",
62
+ "lastUpdated": "2026-03-26T00:34:27.000Z"
63
63
  },
64
64
  "scroll.test.mjs": {
65
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b83113035da665496a3",
66
- "lastUpdated": "2026-03-03T00:32:25.282Z"
65
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ece5d526a093f1e6ca3",
66
+ "lastUpdated": "2026-03-26T00:49:45.385Z"
67
67
  },
68
68
  "scroll-until-image.test.mjs": {
69
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b4549845ced0b71e2b0",
70
- "lastUpdated": "2026-03-03T00:32:25.276Z"
69
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ecad5e55524a4d6ca0b",
70
+ "lastUpdated": "2026-03-26T00:33:14.195Z"
71
71
  },
72
72
  "prompt.test.mjs": {
73
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b45b9fa9df65266123f",
74
- "lastUpdated": "2026-03-03T00:32:25.276Z"
73
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ecb5d526a093f1e6c9e",
74
+ "lastUpdated": "2026-03-26T00:34:30.082Z"
75
75
  },
76
76
  "focus-window.test.mjs": {
77
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b4549845ced0b71e2b1",
78
- "lastUpdated": "2026-03-03T00:32:25.276Z"
77
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ecd6ebfe4f295e78023",
78
+ "lastUpdated": "2026-03-26T00:33:17.098Z"
79
79
  },
80
80
  "captcha-api.test.mjs": {
81
81
  "url": "https://console.testdriver.ai/runs/698f7df69e27ce1528d7d087/698f7fb0d3b320ad547d9d44",
82
82
  "lastUpdated": "2026-02-13T19:55:05.951Z"
83
83
  },
84
84
  "element-not-found.test.mjs": {
85
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b6f0d4a5265e44e7d7b",
86
- "lastUpdated": "2026-03-03T00:32:25.279Z"
85
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ed16ebfe4f295e78027",
86
+ "lastUpdated": "2026-03-26T00:34:36.361Z"
87
87
  },
88
88
  "formatted-logging.test.mjs": {
89
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b60258e8885264fc711",
90
- "lastUpdated": "2026-03-03T00:32:25.279Z"
89
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ed06f887c881af8c67f",
90
+ "lastUpdated": "2026-03-26T00:34:34.692Z"
91
91
  },
92
92
  "hover-text.test.mjs": {
93
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b79dc33133fc0da9439",
94
- "lastUpdated": "2026-03-03T00:32:25.280Z"
93
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ed55d526a093f1e6ca5",
94
+ "lastUpdated": "2026-03-26T00:33:25.098Z"
95
95
  },
96
96
  "no-provision.test.mjs": {
97
97
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b7706a177a05bccd1cf",
98
98
  "lastUpdated": "2026-03-03T00:32:25.279Z"
99
99
  },
100
100
  "ai.test.mjs": {
101
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b8f06a177a05bccd1dc",
102
- "lastUpdated": "2026-03-03T00:32:25.282Z"
101
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ed3d5e55524a4d6ca10",
102
+ "lastUpdated": "2026-03-26T00:53:46.478Z"
103
103
  },
104
104
  "popup-loading.test.mjs": {
105
105
  "url": "https://console.testdriver.ai/runs/698bc89f7140c3fa7daaca8d/698bca7f7140c3fa7daacbf7",
@@ -134,12 +134,12 @@
134
134
  "lastUpdated": "2026-02-13T19:55:05.953Z"
135
135
  },
136
136
  "findall-coffee-icons.test.mjs": {
137
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b7afc0ac3cc632a919b",
138
- "lastUpdated": "2026-03-03T00:32:25.280Z"
137
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ec75d526a093f1e6c9a",
138
+ "lastUpdated": "2026-03-26T00:33:48.000Z"
139
139
  },
140
140
  "parse.test.mjs": {
141
- "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b80aa712ecd3dea731c",
142
- "lastUpdated": "2026-03-03T00:32:25.281Z"
141
+ "url": "https://console-test.testdriver.ai/runs/69c47eafbada9b8191b2daef/69c47ed66ebfe4f295e7802a",
142
+ "lastUpdated": "2026-03-26T00:34:41.328Z"
143
143
  },
144
144
  "flake-diffthreshold-001.test.mjs": {
145
145
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62bcafc0ac3cc632a91aa",
@@ -1,39 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Extract Example URLs from CI Logs
5
- *
6
- * Parses vitest output to extract TESTDRIVER_EXAMPLE_URL lines
7
- * and updates the examples-manifest.json file.
8
- *
4
+ * Extract Example URLs from Test Result JSON Files
5
+ *
6
+ * Reads per-test-case JSON result files written by the vitest plugin
7
+ * to .testdriver/results/ and updates examples-manifest.json.
8
+ *
9
9
  * Usage:
10
- * cat ci-log.txt | node extract-example-urls.js
11
- * node extract-example-urls.js < ci-log.txt
12
- * node extract-example-urls.js --file=ci-log.txt
10
+ * node extract-example-urls.js --results-dir=.testdriver/results
13
11
  */
14
12
 
15
13
  const fs = require("fs");
16
14
  const path = require("path");
17
- const readline = require("readline");
18
15
 
19
16
  const MANIFEST_PATH = path.join(__dirname, "../_data/examples-manifest.json");
20
17
 
21
- // Regex to match TESTDRIVER_EXAMPLE_URL::filename::url (handles optional timestamp prefix from CI logs)
22
- const URL_PATTERN = /TESTDRIVER_EXAMPLE_URL::([^:]+)::(.+)$/;
23
-
24
18
  // Parse command line arguments
25
19
  function parseArgs() {
26
20
  const args = process.argv.slice(2);
27
21
  const options = {
28
- file: null,
22
+ resultsDir: null,
29
23
  help: false,
30
24
  };
31
25
 
32
26
  for (const arg of args) {
33
27
  if (arg === "--help" || arg === "-h") {
34
28
  options.help = true;
35
- } else if (arg.startsWith("--file=")) {
36
- options.file = arg.slice(7);
29
+ } else if (arg.startsWith("--results-dir=")) {
30
+ options.resultsDir = arg.slice(14);
37
31
  }
38
32
  }
39
33
 
@@ -62,40 +56,51 @@ function saveManifest(manifest) {
62
56
  fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
63
57
  }
64
58
 
65
- // Process a single line and extract URL if present
66
- function processLine(line, manifest, stats) {
67
- const match = line.match(URL_PATTERN);
68
- if (match) {
69
- const [, filename, url] = match;
70
- const isNew = !manifest.examples[filename];
71
-
72
- manifest.examples[filename] = {
73
- url: url.trim(),
74
- lastUpdated: new Date().toISOString(),
75
- };
76
-
77
- if (isNew) {
78
- stats.added++;
79
- } else {
80
- stats.updated++;
81
- }
82
-
83
- console.log(`${isNew ? "➕" : "🔄"} ${filename}: ${url}`);
84
- }
85
- }
86
-
87
- // Process input stream
88
- async function processInput(inputStream) {
59
+ // Process JSON result files from .testdriver/results/
60
+ function processResultsDir(resultsDir) {
89
61
  const manifest = loadManifest();
90
62
  const stats = { added: 0, updated: 0 };
91
63
 
92
- const rl = readline.createInterface({
93
- input: inputStream,
94
- crlfDelay: Infinity,
95
- });
64
+ // Look for JSON files under examples/ subdirectories
65
+ const examplesDir = path.join(resultsDir, "examples");
66
+ if (!fs.existsSync(examplesDir)) {
67
+ console.log(`\n⚠️ No examples results found in ${examplesDir}`);
68
+ return stats;
69
+ }
96
70
 
97
- for await (const line of rl) {
98
- processLine(line, manifest, stats);
71
+ // Walk example test directories (e.g., examples/assert.test.mjs/)
72
+ const testDirs = fs.readdirSync(examplesDir, { withFileTypes: true });
73
+ for (const entry of testDirs) {
74
+ if (!entry.isDirectory()) continue;
75
+ const testDir = path.join(examplesDir, entry.name);
76
+ const jsonFiles = fs.readdirSync(testDir).filter(f => f.endsWith(".json"));
77
+
78
+ for (const jsonFile of jsonFiles) {
79
+ try {
80
+ const content = fs.readFileSync(path.join(testDir, jsonFile), "utf-8");
81
+ const result = JSON.parse(content);
82
+ const testFileName = path.basename(result.test?.file || result.testFile || entry.name);
83
+ const url = result.urls?.testRun || result.testRunLink;
84
+
85
+ if (!url) continue;
86
+
87
+ const isNew = !manifest.examples[testFileName];
88
+ manifest.examples[testFileName] = {
89
+ url: url,
90
+ lastUpdated: result.date || new Date().toISOString(),
91
+ };
92
+
93
+ if (isNew) {
94
+ stats.added++;
95
+ } else {
96
+ stats.updated++;
97
+ }
98
+
99
+ console.log(`${isNew ? "➕" : "🔄"} ${testFileName}: ${url}`);
100
+ } catch (err) {
101
+ console.warn(`⚠️ Failed to read ${jsonFile}: ${err.message}`);
102
+ }
103
+ }
99
104
  }
100
105
 
101
106
  if (stats.added > 0 || stats.updated > 0) {
@@ -103,7 +108,7 @@ async function processInput(inputStream) {
103
108
  console.log(`\n✨ Manifest updated: ${stats.added} added, ${stats.updated} updated`);
104
109
  console.log(`📂 Written to: ${MANIFEST_PATH}`);
105
110
  } else {
106
- console.log("\n⚠️ No TESTDRIVER_EXAMPLE_URL entries found in input");
111
+ console.log("\n⚠️ No example URLs found in result files");
107
112
  }
108
113
 
109
114
  return stats;
@@ -112,28 +117,24 @@ async function processInput(inputStream) {
112
117
  // Show help
113
118
  function showHelp() {
114
119
  console.log(`
115
- Extract Example URLs from CI Logs
120
+ Extract Example URLs from Test Result JSON Files
116
121
 
117
122
  Usage:
118
- cat ci-log.txt | node extract-example-urls.js
119
- node extract-example-urls.js < ci-log.txt
120
- node extract-example-urls.js --file=ci-log.txt
123
+ node extract-example-urls.js --results-dir=.testdriver/results
121
124
 
122
125
  Options:
123
- --file=<path> Read from file instead of stdin
124
- --help, -h Show this help message
126
+ --results-dir=<path> Path to .testdriver/results directory (required)
127
+ --help, -h Show this help message
125
128
 
126
129
  Description:
127
- Parses CI log output looking for lines matching:
128
- TESTDRIVER_EXAMPLE_URL::<filename>::<url>
129
-
130
- Updates docs/_data/examples-manifest.json with the extracted URLs.
130
+ Reads per-test-case JSON result files from .testdriver/results/examples/
131
+ and updates docs/_data/examples-manifest.json with the extracted URLs.
131
132
  Existing entries are updated, new entries are added.
132
133
  `);
133
134
  }
134
135
 
135
136
  // Main function
136
- async function main() {
137
+ function main() {
137
138
  const options = parseArgs();
138
139
 
139
140
  if (options.help) {
@@ -141,25 +142,19 @@ async function main() {
141
142
  process.exit(0);
142
143
  }
143
144
 
144
- console.log("🔍 Extracting example URLs from input...\n");
145
-
146
- let inputStream;
147
- if (options.file) {
148
- if (!fs.existsSync(options.file)) {
149
- console.error(`❌ File not found: ${options.file}`);
150
- process.exit(1);
151
- }
152
- inputStream = fs.createReadStream(options.file);
153
- } else {
154
- inputStream = process.stdin;
145
+ if (!options.resultsDir) {
146
+ console.error("❌ --results-dir is required. Example: --results-dir=.testdriver/results");
147
+ process.exit(1);
155
148
  }
156
149
 
157
- try {
158
- await processInput(inputStream);
159
- } catch (error) {
160
- console.error(`❌ Error: ${error.message}`);
150
+ console.log("🔍 Reading example URLs from JSON result files...\n");
151
+
152
+ if (!fs.existsSync(options.resultsDir)) {
153
+ console.error(`❌ Results directory not found: ${options.resultsDir}`);
161
154
  process.exit(1);
162
155
  }
156
+
157
+ processResultsDir(options.resultsDir);
163
158
  }
164
159
 
165
160
  main();
package/docs/docs.json CHANGED
@@ -87,7 +87,8 @@
87
87
  "pages": [
88
88
  "/v7/running-tests",
89
89
  "/v7/caching",
90
- "/v7/ci-cd"
90
+ "/v7/ci-cd",
91
+ "/v7/test-results-json"
91
92
  ]
92
93
  },
93
94
  {
@@ -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.testdriver.ai/api/v1/testdriver/testcase/69a62b8f06a177a05bccd1dc/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ed3d5e55524a4d6ca10/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* assert.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b6206a177a05bccd1cc/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ec55d526a093f1e6c99/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* captcha-api.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/698f7fb0d3b320ad547d9d44/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/698f7fb0d3b320ad547d9d44/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* chrome-extension.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b91fc0ac3cc632a91a0/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47eb16ebfe4f295e78008/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* drag-and-drop.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b42fc0ac3cc632a918b/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69a62b42fc0ac3cc632a918b/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* element-not-found.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b6f0d4a5265e44e7d7b/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ed16ebfe4f295e78027/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* exec-output.test.mjs output */}
14
14
  <iframe
15
- src="https://testdriver-api.onrender.com/api/v1/testdriver/testcase/69a62b42fc0ac3cc632a918c/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ebc5d526a093f1e6c8d/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* exec-pwsh.test.mjs output */}
14
14
  <iframe
15
- src="https://testdriver-api.onrender.com/api/v1/testdriver/testcase/69a62b42565d339e8065f180/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47eb36ebfe4f295e7800a/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* focus-window.test.mjs output */}
14
14
  <iframe
15
- src="https://testdriver-api.onrender.com/api/v1/testdriver/testcase/69a62b4549845ced0b71e2b1/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ecd6ebfe4f295e78023/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* hover-image.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b77fc0ac3cc632a9198/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ebebada9b8191b2daf7/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* hover-text.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b79dc33133fc0da9439/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ed55d526a093f1e6ca5/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* installer.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b570446888b52a4e1c9/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ec06f887c881af8c673/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* launch-vscode-linux.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b91113035da665496a6/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47eb85d526a093f1e6c8c/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* match-image.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b42258e8885264fc704/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47eb56f887c881af8c66b/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
12
12
 
13
13
  {/* press-keys.test.mjs output */}
14
14
  <iframe
15
- src="https://api.testdriver.ai/api/v1/testdriver/testcase/69a62b800d4a5265e44e7d86/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c47ec3d5e55524a4d6ca04/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}