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,258 @@
1
+ ---
2
+ title: "Test Result JSON"
3
+ sidebarTitle: "Test Result JSON"
4
+ description: "Per-test JSON result files with metadata, versions, and infrastructure details"
5
+ icon: "file-code"
6
+ ---
7
+
8
+ ## Overview
9
+
10
+ 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.
11
+
12
+ Result files are written to:
13
+
14
+ ```
15
+ .testdriver/results/<testFile>/<testName>.json
16
+ ```
17
+
18
+ For example, a test file `tests/login.test.mjs` with a test named `"should log in"` produces:
19
+
20
+ ```
21
+ .testdriver/results/tests/login.test.mjs/should_log_in.json
22
+ ```
23
+
24
+ <Note>
25
+ Test names are sanitized for filesystem use — special characters are replaced with underscores and names are truncated to 200 characters.
26
+ </Note>
27
+
28
+ ## Enabling
29
+
30
+ No configuration is required. The JSON files are written automatically by the TestDriver Vitest reporter plugin whenever tests run.
31
+
32
+ ## JSON Schema
33
+
34
+ Each result file is organized into logical groups:
35
+
36
+ ### `versions`
37
+
38
+ | Field | Type | Description |
39
+ |---|---|---|
40
+ | `versions.sdk` | `string \| null` | TestDriver SDK version (e.g. `"7.8.0"`) |
41
+ | `versions.vitest` | `string \| null` | Vitest version used to run the test |
42
+ | `versions.api` | `string \| null` | TestDriver API server version |
43
+ | `versions.runnerBefore` | `string \| null` | Runner version at sandbox start |
44
+ | `versions.runnerAfter` | `string \| null` | Runner version after auto-update |
45
+ | `versions.runnerWasUpdated` | `boolean` | Whether the runner was auto-updated during provisioning |
46
+
47
+ ### `test`
48
+
49
+ | Field | Type | Description |
50
+ |---|---|---|
51
+ | `test.file` | `string \| null` | Relative path to the test file |
52
+ | `test.name` | `string \| null` | Name of the test case |
53
+ | `test.suite` | `string \| null` | Name of the parent `describe` block |
54
+ | `test.passed` | `boolean` | Whether the test passed |
55
+ | `test.caseId` | `string \| null` | Database ID for this test case |
56
+ | `test.runId` | `string \| null` | Database ID for the overall test run |
57
+ | `test.error` | `string \| null` | Error message if the test failed |
58
+ | `test.errorStack` | `string \| null` | Error stack trace if the test failed |
59
+
60
+ ### `urls`
61
+
62
+ | Field | Type | Description |
63
+ |---|---|---|
64
+ | `urls.api` | `string \| null` | API root URL used for this test |
65
+ | `urls.console` | `string \| null` | TestDriver console base URL |
66
+ | `urls.vnc` | `string \| null` | VNC URL for the sandbox |
67
+ | `urls.testRun` | `string \| null` | Direct link to this test case in the console |
68
+
69
+ ### `replay`
70
+
71
+ The `replay` object contains the recording replay URL and derived embed links. The `gifUrl` and `embedUrl` are generated automatically from the replay URL.
72
+
73
+ | Field | Type | Description |
74
+ |---|---|---|
75
+ | `replay.url` | `string \| null` | Recording replay URL |
76
+ | `replay.gifUrl` | `string \| null` | Animated GIF thumbnail of the recording |
77
+ | `replay.embedUrl` | `string \| null` | Embeddable replay URL (appends `&embed=true`) |
78
+ | `replay.markdown` | `string \| null` | Ready-to-use Markdown embed with GIF linking to the replay |
79
+
80
+ The `replay.markdown` field produces a clickable GIF badge you can paste directly into PR comments, README files, or issue descriptions:
81
+
82
+ ```markdown
83
+ [![Test Recording](https://api.testdriver.ai/replay/abc123/gif?shareKey=xyz)](https://console.testdriver.ai/replay/abc123?share=xyz)
84
+ ```
85
+
86
+ ### `date`
87
+
88
+ | Field | Type | Description |
89
+ |---|---|---|
90
+ | `date` | `string` | ISO 8601 timestamp when the test finished |
91
+
92
+ ### `team`
93
+
94
+ | Field | Type | Description |
95
+ |---|---|---|
96
+ | `team.id` | `string \| null` | Team ID from the sandbox |
97
+ | `team.sessionId` | `string \| null` | SDK session ID |
98
+
99
+ ### `infrastructure`
100
+
101
+ | Field | Type | Description |
102
+ |---|---|---|
103
+ | `infrastructure.sandboxId` | `string \| null` | Sandbox instance ID |
104
+ | `infrastructure.instanceId` | `string \| null` | Instance ID |
105
+ | `infrastructure.os` | `string \| null` | Operating system of the sandbox (`"linux"` or `"windows"`) |
106
+ | `infrastructure.amiId` | `string \| null` | AWS AMI ID used for provisioning |
107
+ | `infrastructure.e2bTemplateId` | `string \| null` | E2B template ID used for provisioning |
108
+ | `infrastructure.imageVersion` | `string \| null` | Sandbox image version |
109
+
110
+ ### `realtime`
111
+
112
+ | Field | Type | Description |
113
+ |---|---|---|
114
+ | `realtime.channel` | `string \| null` | Ably channel name used for communication |
115
+ | `realtime.messageCount` | `number` | Number of messages published to the realtime channel |
116
+
117
+ ### `interactions`
118
+
119
+ | Field | Type | Description |
120
+ |---|---|---|
121
+ | `interactions.total` | `number` | Total number of interactions recorded |
122
+ | `interactions.cached` | `number` | Number of interactions served from cache |
123
+ | `interactions.byType` | `object` | Breakdown of interactions by type (e.g. `find`, `click`, `assert`) |
124
+
125
+ ## Example Output
126
+
127
+ ```json
128
+ {
129
+ "sdkVersion": "7.8.0",
130
+ "vitestVersion": "4.0.0",
131
+ "apiVersion": "1.45.0",
132
+ "runnerVersionBefore": "2.1.0",
133
+ "runnerVersionAfter": "2.1.1",
134
+ "wasUpdated": true,
135
+ "apiUrl": "https://api.testdriver.ai",
136
+ "consoleUrl": "https://console.testdriver.ai",
137
+ "testRunLink": "https://console.testdriver.ai/runs/abc123/def456",
138
+ "dashcamUrl": "https://app.dashcam.io/replay/abc123",
139
+ "vncUrl": "wss://sandbox-123.testdriver.ai/vnc",
140
+ "date": "2025-01-15T14:30:00.000Z",
141
+ "team": {
142
+ "id": "team_abc123",
143
+ "sessionId": "sess_xyz789"
144
+ },
145
+ "infrastructure": {
146
+ "sandboxId": "sandbox-123",
147
+ "instanceId": "i-abc123",
148
+ "os": "linux",
149
+ "amiId": "ami-0abc123",
150
+ "e2bTemplateId": null,
151
+ "imageVersion": "v2.1.0"
152
+ },
153
+ "realtime": {
154
+ "channel": "sandbox:sandbox-123",
155
+ "messageCount": 42
156
+ },
157
+ "interactions": {
158
+ "total": 15,
159
+ "cached": 3,
160
+ "byType": {
161
+ "find": 8,
162
+ "click": 5,
163
+ "assert": 2
164
+ }
165
+ }
166
+ }
167
+ ```
168
+
169
+ ## Using Result Files in CI
170
+
171
+ Result files are useful for extracting test metadata in CI pipelines without parsing log output.
172
+
173
+ ### GitHub Actions Example
174
+
175
+ Use `fromJSON` to parse a result file into a GitHub Actions expression you can reference in subsequent steps:
176
+
177
+ ```yaml
178
+ - name: Run tests
179
+ run: npx vitest run tests/login.test.mjs
180
+
181
+ - name: Parse result
182
+ id: result
183
+ run: |
184
+ # Read the first JSON result file
185
+ FILE=$(find .testdriver/results -name '*.json' | head -n 1)
186
+ echo "json=$(cat "$FILE")" >> "$GITHUB_OUTPUT"
187
+
188
+ - name: Comment on PR
189
+ if: fromJSON(steps.result.outputs.json).test.passed == false
190
+ uses: actions/github-script@v7
191
+ with:
192
+ script: |
193
+ const result = ${{ steps.result.outputs.json }};
194
+ await github.rest.issues.createComment({
195
+ owner: context.repo.owner,
196
+ repo: context.repo.repo,
197
+ issue_number: context.issue.number,
198
+ body: [
199
+ `❌ **${result.test.name}** failed`,
200
+ ``,
201
+ `Error: ${result.test.error}`,
202
+ ``,
203
+ result.replay.markdown,
204
+ ``,
205
+ `[View full recording](${result.urls.testRun})`
206
+ ].join('\n')
207
+ });
208
+ ```
209
+
210
+ You can also load all results into a matrix or iterate over them:
211
+
212
+ ```yaml
213
+ - name: Run tests
214
+ run: npx vitest run tests/*.test.mjs
215
+
216
+ - name: Collect results
217
+ id: results
218
+ run: |
219
+ # Merge all result files into a JSON array
220
+ echo "json=$(find .testdriver/results -name '*.json' -exec cat {} + | jq -s '.')" >> "$GITHUB_OUTPUT"
221
+
222
+ - name: Summary
223
+ run: |
224
+ echo '## Test Results' >> $GITHUB_STEP_SUMMARY
225
+ RESULTS='${{ steps.results.outputs.json }}'
226
+ echo "$RESULTS" | jq -r '.[] | "| \(.test.name) | \(if .test.passed then "✅" else "❌" end) | \(.urls.testRun) |"' >> $GITHUB_STEP_SUMMARY
227
+ ```
228
+
229
+ ### Reading Results Programmatically
230
+
231
+ ```javascript
232
+ import fs from "fs";
233
+ import path from "path";
234
+
235
+ const resultsDir = ".testdriver/results";
236
+
237
+ function readResults(dir) {
238
+ const results = [];
239
+ for (const testDir of fs.readdirSync(dir, { recursive: true })) {
240
+ const fullPath = path.join(dir, testDir);
241
+ if (fullPath.endsWith(".json") && fs.statSync(fullPath).isFile()) {
242
+ results.push(JSON.parse(fs.readFileSync(fullPath, "utf-8")));
243
+ }
244
+ }
245
+ return results;
246
+ }
247
+
248
+ const results = readResults(resultsDir);
249
+ const passed = results.filter(r => r.test.passed);
250
+ const failed = results.filter(r => !r.test.passed);
251
+
252
+ console.log(`${passed.length} passed, ${failed.length} failed`);
253
+ for (const r of failed) {
254
+ console.log(` FAIL: ${r.test.name} — ${r.test.error}`);
255
+ console.log(` Recording: ${r.urls.testRun}`);
256
+ console.log(` Embed: ${r.replay.markdown}`);
257
+ }
258
+ ```
@@ -16,7 +16,7 @@ describe("Scroll Keyboard Test", () => {
16
16
  // Navigate to https://www.webhamster.com/
17
17
  await testdriver.focusApplication("Google Chrome");
18
18
  const urlBar = await testdriver.find(
19
- "testdriver-sandbox.vercel.app/login, the URL in the omnibox showing the current page", {zoom: true}
19
+ "the URL in the omnibox", {zoom: true}
20
20
  );
21
21
  await urlBar.click();
22
22
  await testdriver.pressKeys(["ctrl", "a"]);
@@ -12,19 +12,8 @@ import { getDefaults } from "./config.mjs";
12
12
  describe("Scroll Test", () => {
13
13
  it("should navigate and scroll down the page", async (context) => {
14
14
  const testdriver = TestDriver(context, { ...getDefaults(context), headless: true });
15
- await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
15
+ await testdriver.provision.chrome({ url: 'https://www.webhamster.com/' });
16
16
 
17
- // Give Chrome a moment to fully render the UI
18
- await new Promise(resolve => setTimeout(resolve, 2000));
19
-
20
- // Navigate to webhamster.com - just look for the domain, not the full path
21
- const urlBar = await testdriver.find(
22
- "testdriver-sandbox.vercel.app, the URL in the address bar",
23
- );
24
- await urlBar.click();
25
- await testdriver.pressKeys(["ctrl", "a"]);
26
- await testdriver.type("https://www.webhamster.com/");
27
- await testdriver.pressKeys(["enter"]);
28
17
 
29
18
  // Wait for page to load and click heading
30
19
  const heading = await testdriver.find(
@@ -24,18 +24,6 @@ class CustomTransport extends Transport {
24
24
  return;
25
25
  }
26
26
 
27
- if (!this.sandbox) {
28
- this.sandbox = require("../agent/lib/sandbox");
29
- }
30
-
31
- if (this.sandbox && this.sandbox.instanceSocketConnected) {
32
- this.sandbox.send({
33
- type: "output",
34
- output: Buffer.from(message).toString("base64"),
35
- }).catch((e) => {
36
- console.error("Error sending log:", e);
37
- });
38
- }
39
27
  } catch (e) {
40
28
  console.error("Error in CustomTransport log method:", e);
41
29
  }