testdriverai 7.8.0-test.7 → 7.8.0-test.71

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 (98) hide show
  1. package/agent/index.js +18 -5
  2. package/agent/lib/commands.js +3 -2
  3. package/agent/lib/http.js +162 -0
  4. package/agent/lib/logger.js +15 -0
  5. package/agent/lib/sandbox.js +554 -209
  6. package/agent/lib/sdk.js +5 -22
  7. package/agent/lib/system.js +25 -65
  8. package/ai/skills/testdriver-cache/SKILL.md +221 -0
  9. package/ai/skills/testdriver-errors/SKILL.md +246 -0
  10. package/ai/skills/testdriver-events/SKILL.md +356 -0
  11. package/ai/skills/testdriver-find/SKILL.md +14 -20
  12. package/ai/skills/testdriver-mcp/SKILL.md +7 -0
  13. package/ai/skills/testdriver-provision/SKILL.md +331 -0
  14. package/ai/skills/testdriver-redraw/SKILL.md +214 -0
  15. package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
  16. package/ai/skills/testdriver-screenshots/SKILL.md +184 -0
  17. package/docs/_data/examples-manifest.json +46 -46
  18. package/docs/_scripts/extract-example-urls.js +67 -72
  19. package/docs/changelog.mdx +148 -8
  20. package/docs/docs.json +46 -38
  21. package/docs/images/content/vscode/v7-chat.png +0 -0
  22. package/docs/images/content/vscode/v7-choose-agent.png +0 -0
  23. package/docs/images/content/vscode/v7-full.png +0 -0
  24. package/docs/images/content/vscode/v7-onboarding.png +0 -0
  25. package/docs/v7/cache.mdx +223 -0
  26. package/docs/v7/copilot/auto-healing.mdx +265 -0
  27. package/docs/v7/copilot/creating-tests.mdx +156 -0
  28. package/docs/v7/copilot/github.mdx +143 -0
  29. package/docs/v7/copilot/running-tests.mdx +149 -0
  30. package/docs/v7/copilot/setup.mdx +143 -0
  31. package/docs/v7/enterprise.mdx +3 -110
  32. package/docs/v7/errors.mdx +248 -0
  33. package/docs/v7/events.mdx +358 -0
  34. package/docs/v7/examples/ai.mdx +1 -1
  35. package/docs/v7/examples/assert.mdx +1 -1
  36. package/docs/v7/examples/captcha-api.mdx +1 -1
  37. package/docs/v7/examples/chrome-extension.mdx +1 -1
  38. package/docs/v7/examples/drag-and-drop.mdx +1 -1
  39. package/docs/v7/examples/element-not-found.mdx +1 -1
  40. package/docs/v7/examples/exec-output.mdx +85 -0
  41. package/docs/v7/examples/exec-pwsh.mdx +83 -0
  42. package/docs/v7/examples/focus-window.mdx +62 -0
  43. package/docs/v7/examples/hover-image.mdx +1 -1
  44. package/docs/v7/examples/hover-text.mdx +1 -1
  45. package/docs/v7/examples/installer.mdx +1 -1
  46. package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
  47. package/docs/v7/examples/match-image.mdx +1 -1
  48. package/docs/v7/examples/press-keys.mdx +1 -1
  49. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  50. package/docs/v7/examples/scroll-until-image.mdx +1 -1
  51. package/docs/v7/examples/scroll-until-text.mdx +1 -1
  52. package/docs/v7/examples/scroll.mdx +1 -1
  53. package/docs/v7/examples/type.mdx +1 -1
  54. package/docs/v7/examples/windows-installer.mdx +1 -1
  55. package/docs/v7/find.mdx +14 -20
  56. package/docs/v7/{cloud.mdx → hosted.mdx} +43 -5
  57. package/docs/v7/mcp.mdx +9 -0
  58. package/docs/v7/provision.mdx +333 -0
  59. package/docs/v7/quickstart.mdx +30 -2
  60. package/docs/v7/redraw.mdx +216 -0
  61. package/docs/v7/running-tests.mdx +1 -1
  62. package/docs/v7/screenshots.mdx +186 -0
  63. package/docs/v7/self-hosted.mdx +127 -44
  64. package/docs/v7/test-results-json.mdx +258 -0
  65. package/examples/scroll-keyboard.test.mjs +1 -1
  66. package/examples/scroll.test.mjs +1 -12
  67. package/interfaces/logger.js +0 -12
  68. package/interfaces/vitest-plugin.mjs +170 -51
  69. package/lib/core/Dashcam.js +30 -23
  70. package/lib/environments.json +22 -0
  71. package/lib/github-comment.mjs +58 -40
  72. package/lib/init-project.js +5 -67
  73. package/lib/resolve-channel.js +42 -12
  74. package/lib/sentry.js +47 -23
  75. package/lib/vitest/hooks.mjs +63 -3
  76. package/{examples → manual}/drag-and-drop.test.mjs +1 -1
  77. package/manual/exec-stream-logs.test.mjs +25 -0
  78. package/mcp-server/dist/server.mjs +28 -8
  79. package/mcp-server/src/server.ts +31 -8
  80. package/package.json +4 -3
  81. package/sdk.d.ts +4 -0
  82. package/sdk.js +45 -15
  83. package/setup/aws/install-dev-runner.sh +79 -0
  84. package/setup/aws/spawn-runner.sh +165 -0
  85. package/test-sentry-span.js +35 -0
  86. package/vitest.config.mjs +22 -34
  87. package/vitest.runner.config.mjs +33 -0
  88. /package/{examples → manual}/flake-diffthreshold-001.test.mjs +0 -0
  89. /package/{examples → manual}/flake-diffthreshold-01.test.mjs +0 -0
  90. /package/{examples → manual}/flake-diffthreshold-05.test.mjs +0 -0
  91. /package/{examples → manual}/flake-noredraw-cache.test.mjs +0 -0
  92. /package/{examples → manual}/flake-noredraw-nocache.test.mjs +0 -0
  93. /package/{examples → manual}/flake-redraw-cache.test.mjs +0 -0
  94. /package/{examples → manual}/flake-redraw-nocache.test.mjs +0 -0
  95. /package/{examples → manual}/flake-rocket-match.test.mjs +0 -0
  96. /package/{examples → manual}/flake-shared.mjs +0 -0
  97. /package/{examples → manual}/no-provision.test.mjs +0 -0
  98. /package/{examples → manual}/scroll-until-text.test.mjs +0 -0
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: testdriver:screenshots
3
+ description: Capture and manage screenshots during test execution
4
+ ---
5
+ <!-- Generated from screenshots.mdx. DO NOT EDIT. -->
6
+
7
+ ## Overview
8
+
9
+ TestDriver can capture screenshots manually at any point during a test, or automatically before and after every command. Screenshots are saved to a structured directory for easy debugging.
10
+
11
+ ## Manual Screenshots
12
+
13
+ Use `testdriver.screenshot()` to capture the current screen:
14
+
15
+ ```javascript
16
+ const path = await testdriver.screenshot();
17
+ console.log('Saved to:', path);
18
+ // .testdriver/screenshots/my-test/screenshot-1719849312345.png
19
+ ```
20
+
21
+ ### Options
22
+
23
+ ```javascript
24
+ await testdriver.screenshot(filename?)
25
+ ```
26
+
27
+ <ParamField path="filename" type="string">
28
+ Custom filename for the screenshot. `.png` is appended automatically if missing. If omitted, defaults to `screenshot-<timestamp>.png`.
29
+ </ParamField>
30
+
31
+ **Returns:** `Promise<string>` — the absolute file path of the saved screenshot.
32
+
33
+ ```javascript
34
+ // Default filename
35
+ await testdriver.screenshot();
36
+ // → .testdriver/screenshots/my-test/screenshot-1719849312345.png
37
+
38
+ // Custom filename
39
+ await testdriver.screenshot('login-page');
40
+ // → .testdriver/screenshots/my-test/login-page.png
41
+
42
+ // With .png extension
43
+ await testdriver.screenshot('dashboard-loaded.png');
44
+ // → .testdriver/screenshots/my-test/dashboard-loaded.png
45
+ ```
46
+
47
+ ## Auto Screenshots
48
+
49
+ Enable automatic screenshots before and after every command:
50
+
51
+ ```javascript
52
+ const testdriver = new TestDriver({
53
+ autoScreenshots: true,
54
+ });
55
+ ```
56
+
57
+ <ParamField path="autoScreenshots" type="boolean" default={false}>
58
+ When `true`, captures a screenshot before and after every SDK command (`click`, `type`, `find`, `scroll`, `hover`, `pressKeys`, `assert`, `exec`, etc.). On error, an error-phase screenshot replaces the after-phase screenshot.
59
+ </ParamField>
60
+
61
+ ### Filename Format
62
+
63
+ Auto-screenshots follow this naming convention:
64
+
65
+ ```
66
+ <seq>-<action>-<phase>-L<line>-<description>.png
67
+ ```
68
+
69
+ | Part | Description | Example |
70
+ |---|---|---|
71
+ | `seq` | 3-digit zero-padded sequence number | `001` |
72
+ | `action` | Command name | `click`, `type`, `find` |
73
+ | `phase` | `before`, `after`, or `error` | `before` |
74
+ | `L<line>` | Source line number from your test file | `L42` |
75
+ | `description` | Sanitized from command arguments (max 30 chars) | `submit-button` |
76
+
77
+ **Examples:**
78
+ ```
79
+ 001-find-before-L15-login-button.png
80
+ 002-find-after-L15-login-button.png
81
+ 003-click-before-L16-login-button.png
82
+ 004-click-after-L16-login-button.png
83
+ 005-type-before-L18-username-field.png
84
+ 006-type-error-L18-username-field.png
85
+ ```
86
+
87
+ ### Phases
88
+
89
+ | Phase | When | Description |
90
+ |---|---|---|
91
+ | `before` | Before command executes | Captures the screen state before the action |
92
+ | `after` | After successful command | Captures the result of the action |
93
+ | `error` | After failed command | Captures the screen at the point of failure (replaces `after`) |
94
+
95
+ ## Screenshot Directory
96
+
97
+ Screenshots are saved to:
98
+
99
+ ```
100
+ <cwd>/.testdriver/screenshots/<testFileName>/
101
+ ```
102
+
103
+ Where `<testFileName>` is the test file name without its extension. For example, a test at `tests/login.test.mjs` saves screenshots to `.testdriver/screenshots/login.test/`.
104
+
105
+ ### Directory Cleanup
106
+
107
+ The screenshot directory for each test file is **automatically cleaned** at the start of a test run. This happens once per process per test file to prevent concurrent tests from the same file from interfering with each other.
108
+
109
+ ## Debug Screenshots
110
+
111
+ Elements have a `saveDebugScreenshot()` method for debugging element detection:
112
+
113
+ ```javascript
114
+ const el = await testdriver.find('submit button');
115
+
116
+ // Save the screenshot that was used to detect this element
117
+ const debugPath = await el.saveDebugScreenshot();
118
+ console.log('Debug screenshot:', debugPath);
119
+ // → ./debug-screenshot-1719849312345.png
120
+
121
+ // Custom path
122
+ await el.saveDebugScreenshot('./my-debug.png');
123
+ ```
124
+
125
+ This saves the screenshot that was captured during the `find()` call, which can be useful for understanding what the AI "saw" when locating the element.
126
+
127
+ ## Complete Example
128
+
129
+ ```javascript
130
+ import { describe, it, beforeAll, afterAll } from 'vitest';
131
+ import TestDriver from 'testdriverai';
132
+
133
+ describe('Screenshot Example', () => {
134
+ let testdriver;
135
+
136
+ beforeAll(async () => {
137
+ testdriver = new TestDriver({
138
+ autoScreenshots: true, // capture every step
139
+ });
140
+ await testdriver.ready();
141
+ await testdriver.provision.chrome({ url: 'https://example.com' });
142
+ });
143
+
144
+ afterAll(async () => {
145
+ await testdriver.disconnect();
146
+ });
147
+
148
+ it('captures the login flow', async () => {
149
+ // Auto-screenshots capture before/after each command
150
+
151
+ // Manual screenshot for a specific moment
152
+ await testdriver.screenshot('initial-page-load');
153
+
154
+ const username = await testdriver.find('username input');
155
+ await username.click();
156
+ await testdriver.type('testuser@example.com');
157
+
158
+ await testdriver.screenshot('after-username-entry');
159
+
160
+ const password = await testdriver.find('password input');
161
+ await password.click();
162
+ await testdriver.type('password123');
163
+
164
+ await testdriver.find('login button').click();
165
+
166
+ await testdriver.screenshot('after-login-click');
167
+ });
168
+ });
169
+ ```
170
+
171
+ After running, your screenshot directory will contain:
172
+ ```
173
+ .testdriver/screenshots/login-flow.test/
174
+ ├── initial-page-load.png
175
+ ├── 001-find-before-L18-username-input.png
176
+ ├── 002-find-after-L18-username-input.png
177
+ ├── 003-click-before-L19-username-input.png
178
+ ├── 004-click-after-L19-username-input.png
179
+ ├── 005-type-before-L20-testuser-example-com.png
180
+ ├── 006-type-after-L20-testuser-example-com.png
181
+ ├── after-username-entry.png
182
+ ├── 007-find-before-L24-password-input.png
183
+ ├── ...
184
+ ```
@@ -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/69c32c95b4a333234cc21a6c/69c32ca86560e1c6d04ac340",
6
+ "lastUpdated": "2026-03-25T00:36:26.387Z"
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/69c32c95b4a333234cc21a6c/69c32c9816690e8f8d0fd3a7",
14
+ "lastUpdated": "2026-03-25T00:31:30.158Z"
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/69c32c95b4a333234cc21a6c/69c32c9a6560e1c6d04ac33c",
18
+ "lastUpdated": "2026-03-25T00:31:31.550Z"
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/69c32c95b4a333234cc21a6c/69c32c9b6f1e64e218b9e1c1",
26
+ "lastUpdated": "2026-03-25T00:30:19.815Z"
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/69c32c95b4a333234cc21a6c/69c32c9e6f1e64e218b9e1c3",
30
+ "lastUpdated": "2026-03-25T00:31:36.152Z"
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/69c32c95b4a333234cc21a6c/69c32ca06560e1c6d04ac33e",
34
+ "lastUpdated": "2026-03-25T00:31:37.612Z"
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/69c32c95b4a333234cc21a6c/69c32c9716690e8f8d0fd3a6",
38
+ "lastUpdated": "2026-03-25T00:30:51.808Z"
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/69c32c95b4a333234cc21a6c/69c32c9d6560e1c6d04ac33d",
42
+ "lastUpdated": "2026-03-25T00:33:18.181Z"
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/69c32c95b4a333234cc21a6c/69c32ca16f1e64e218b9e1c5",
46
+ "lastUpdated": "2026-03-25T00:31:02.500Z"
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/69c32c95b4a333234cc21a6c/69c32ca3b4a333234cc21a71",
50
+ "lastUpdated": "2026-03-25T00:30:27.405Z"
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/69c32c95b4a333234cc21a6c/69c32ca56560e1c6d04ac33f",
54
+ "lastUpdated": "2026-03-25T00:31:05.803Z"
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/69c32c95b4a333234cc21a6c/69c32ca6b4a333234cc21a72",
58
+ "lastUpdated": "2026-03-25T00:36:02.167Z"
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/69c32c95b4a333234cc21a6c/69c32cab6f1e64e218b9e1c8",
62
+ "lastUpdated": "2026-03-25T00:31:48.884Z"
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/69c32c95b4a333234cc21a6c/69c32cb1ca96d9648a141714",
66
+ "lastUpdated": "2026-03-25T00:37:40.747Z"
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/69c32c95b4a333234cc21a6c/69c32cad6560e1c6d04ac342",
70
+ "lastUpdated": "2026-03-25T00:30:37.291Z"
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/69c32c95b4a333234cc21a6c/69c32cae6f1e64e218b9e1c9",
74
+ "lastUpdated": "2026-03-25T00:31:51.753Z"
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/69c32c95b4a333234cc21a6c/69c32cb0ca96d9648a141713",
78
+ "lastUpdated": "2026-03-25T00:30:40.087Z"
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/69c32c95b4a333234cc21a6c/69c32cb5ca96d9648a141716",
86
+ "lastUpdated": "2026-03-25T00:31:57.845Z"
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/69c32c95b4a333234cc21a6c/69c32cb36f1e64e218b9e1cb",
90
+ "lastUpdated": "2026-03-25T00:31:56.270Z"
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/69c32c95b4a333234cc21a6c/69c32cb86f1e64e218b9e1cd",
94
+ "lastUpdated": "2026-03-25T00:30:48.128Z"
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/69c32c95b4a333234cc21a6c/69c32cb6ca96d9648a141717",
102
+ "lastUpdated": "2026-03-25T00:38:54.978Z"
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/69c32c95b4a333234cc21a6c/69c32caa6f1e64e218b9e1c7",
138
+ "lastUpdated": "2026-03-25T00:31:10.542Z"
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/69c32c95b4a333234cc21a6c/69c32cb96560e1c6d04ac34e",
142
+ "lastUpdated": "2026-03-25T00:32:02.419Z"
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();