testdriverai 7.0.0 → 7.1.0

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 (112) hide show
  1. package/AGENTS.md +550 -0
  2. package/CODEOWNERS +0 -1
  3. package/README.md +126 -0
  4. package/agent/index.js +43 -18
  5. package/agent/lib/commands.js +794 -135
  6. package/agent/lib/redraw.js +124 -39
  7. package/agent/lib/sandbox.js +10 -1
  8. package/agent/lib/sdk.js +21 -0
  9. package/docs/MIGRATION.md +425 -0
  10. package/docs/PRESETS.md +210 -0
  11. package/docs/docs.json +91 -37
  12. package/docs/guide/best-practices-polling.mdx +154 -0
  13. package/docs/v7/api/dashcam.mdx +497 -0
  14. package/docs/v7/api/doubleClick.mdx +102 -0
  15. package/docs/v7/api/mouseDown.mdx +161 -0
  16. package/docs/v7/api/mouseUp.mdx +164 -0
  17. package/docs/v7/api/rightClick.mdx +123 -0
  18. package/docs/v7/getting-started/configuration.mdx +380 -0
  19. package/docs/v7/getting-started/quickstart.mdx +273 -140
  20. package/docs/v7/guides/best-practices.mdx +486 -0
  21. package/docs/v7/guides/caching-ai.mdx +215 -0
  22. package/docs/v7/guides/caching-selectors.mdx +292 -0
  23. package/docs/v7/guides/caching.mdx +366 -0
  24. package/docs/v7/guides/ci-cd/azure.mdx +587 -0
  25. package/docs/v7/guides/ci-cd/circleci.mdx +523 -0
  26. package/docs/v7/guides/ci-cd/github-actions.mdx +457 -0
  27. package/docs/v7/guides/ci-cd/gitlab.mdx +498 -0
  28. package/docs/v7/guides/ci-cd/jenkins.mdx +664 -0
  29. package/docs/v7/guides/ci-cd/travis.mdx +438 -0
  30. package/docs/v7/guides/debugging.mdx +349 -0
  31. package/docs/v7/guides/faq.mdx +393 -0
  32. package/docs/v7/guides/performance.mdx +517 -0
  33. package/docs/v7/guides/troubleshooting.mdx +526 -0
  34. package/docs/v7/guides/vitest-plugin.mdx +477 -0
  35. package/docs/v7/guides/vitest.mdx +535 -0
  36. package/docs/v7/platforms/linux.mdx +308 -0
  37. package/docs/v7/platforms/macos.mdx +433 -0
  38. package/docs/v7/platforms/windows.mdx +430 -0
  39. package/docs/v7/presets/chrome-extension.mdx +223 -0
  40. package/docs/v7/presets/chrome.mdx +287 -0
  41. package/docs/v7/presets/electron.mdx +435 -0
  42. package/docs/v7/presets/vscode.mdx +398 -0
  43. package/docs/v7/presets/webapp.mdx +396 -0
  44. package/docs/v7/progressive-apis/CORE.md +459 -0
  45. package/docs/v7/progressive-apis/HOOKS.md +360 -0
  46. package/docs/v7/progressive-apis/PROGRESSIVE_DISCLOSURE.md +230 -0
  47. package/docs/v7/progressive-apis/PROVISION.md +266 -0
  48. package/interfaces/vitest-plugin.mjs +186 -100
  49. package/package.json +12 -1
  50. package/sdk.d.ts +335 -42
  51. package/sdk.js +756 -95
  52. package/src/core/Dashcam.js +469 -0
  53. package/src/core/index.d.ts +150 -0
  54. package/src/core/index.js +12 -0
  55. package/src/presets/index.mjs +331 -0
  56. package/src/vitest/extended.mjs +108 -0
  57. package/src/vitest/hooks.d.ts +119 -0
  58. package/src/vitest/hooks.mjs +298 -0
  59. package/src/vitest/index.mjs +64 -0
  60. package/src/vitest/lifecycle.mjs +277 -0
  61. package/src/vitest/utils.mjs +150 -0
  62. package/test/dashcam.test.js +137 -0
  63. package/testdriver/acceptance-sdk/assert.test.mjs +13 -31
  64. package/testdriver/acceptance-sdk/auto-cache-key-demo.test.mjs +56 -0
  65. package/testdriver/acceptance-sdk/chrome-extension.test.mjs +89 -0
  66. package/testdriver/acceptance-sdk/drag-and-drop.test.mjs +7 -19
  67. package/testdriver/acceptance-sdk/element-not-found.test.mjs +6 -19
  68. package/testdriver/acceptance-sdk/exec-js.test.mjs +6 -18
  69. package/testdriver/acceptance-sdk/exec-output.test.mjs +8 -20
  70. package/testdriver/acceptance-sdk/exec-pwsh.test.mjs +13 -25
  71. package/testdriver/acceptance-sdk/focus-window.test.mjs +8 -20
  72. package/testdriver/acceptance-sdk/formatted-logging.test.mjs +5 -20
  73. package/testdriver/acceptance-sdk/hooks-example.test.mjs +38 -0
  74. package/testdriver/acceptance-sdk/hover-image.test.mjs +10 -19
  75. package/testdriver/acceptance-sdk/hover-text-with-description.test.mjs +7 -19
  76. package/testdriver/acceptance-sdk/hover-text.test.mjs +5 -19
  77. package/testdriver/acceptance-sdk/match-image.test.mjs +7 -19
  78. package/testdriver/acceptance-sdk/presets-example.test.mjs +87 -0
  79. package/testdriver/acceptance-sdk/press-keys.test.mjs +5 -19
  80. package/testdriver/acceptance-sdk/prompt.test.mjs +6 -18
  81. package/testdriver/acceptance-sdk/scroll-keyboard.test.mjs +6 -20
  82. package/testdriver/acceptance-sdk/scroll-until-image.test.mjs +6 -18
  83. package/testdriver/acceptance-sdk/scroll-until-text.test.mjs +9 -23
  84. package/testdriver/acceptance-sdk/scroll.test.mjs +12 -21
  85. package/testdriver/acceptance-sdk/setup/testHelpers.mjs +124 -352
  86. package/testdriver/acceptance-sdk/sully-ai.test.mjs +234 -0
  87. package/testdriver/acceptance-sdk/test-console-logs.test.mjs +42 -0
  88. package/testdriver/acceptance-sdk/type.test.mjs +19 -58
  89. package/vitest.config.mjs +1 -0
  90. package/.vscode/mcp.json +0 -9
  91. package/MIGRATION.md +0 -389
  92. package/PLUGIN_MIGRATION.md +0 -222
  93. package/PROMPT_CACHE.md +0 -200
  94. package/SDK_LOGGING.md +0 -222
  95. package/SDK_MIGRATION.md +0 -474
  96. package/SDK_README.md +0 -1122
  97. package/debug-screenshot-1763401388589.png +0 -0
  98. package/examples/run-tests-with-recording.sh +0 -70
  99. package/examples/screenshot-example.js +0 -63
  100. package/examples/sdk-awesome-logs-demo.js +0 -177
  101. package/examples/sdk-cache-thresholds.js +0 -96
  102. package/examples/sdk-element-properties.js +0 -155
  103. package/examples/sdk-simple-example.js +0 -65
  104. package/examples/test-recording-example.test.js +0 -166
  105. package/mcp-server/AI_GUIDELINES.md +0 -57
  106. package/test-find-api.js +0 -73
  107. package/test-prompt-cache.js +0 -96
  108. package/test-sandbox-render.js +0 -28
  109. package/test-sdk-methods.js +0 -15
  110. package/test-sdk-refactor.js +0 -53
  111. package/test-stack-trace.mjs +0 -57
  112. package/testdriver/acceptance-sdk/setup/lifecycleHelpers.mjs +0 -239
@@ -1,166 +0,0 @@
1
- /**
2
- * Example Vitest test file demonstrating TestDriver test recording
3
- *
4
- * This example shows how to:
5
- * 1. Use TestDriver SDK in tests
6
- * 2. Associate dashcam recordings with tests
7
- * 3. Record custom test metadata
8
- *
9
- * Run with: npx vitest run examples/test-recording-example.test.js
10
- */
11
-
12
- import { afterAll, beforeAll, describe, test } from "vitest";
13
- import TestDriverSDK from "../sdk.js";
14
-
15
- // Initialize TestDriver client
16
- let client;
17
- let runId;
18
-
19
- beforeAll(async () => {
20
- // Connect to TestDriver
21
- client = new TestDriverSDK({
22
- apiKey: process.env.TD_API_KEY || "your-api-key",
23
- });
24
-
25
- await client.connect();
26
-
27
- // Create a test run (usually done by the Vitest reporter, but shown here for demo)
28
- runId = `example-${Date.now()}`;
29
-
30
- const testRun = await client.createTestRun({
31
- runId,
32
- suiteName: "Example Test Suite",
33
- platform: "windows",
34
- git: {
35
- repo: "testdriverai/cli",
36
- branch: "main",
37
- commit: "abc123",
38
- },
39
- });
40
-
41
- console.log("Test run created:", testRun.runId);
42
- });
43
-
44
- afterAll(async () => {
45
- // Complete the test run
46
- await client.completeTestRun({
47
- runId,
48
- status: "passed",
49
- totalTests: 3,
50
- passedTests: 3,
51
- failedTests: 0,
52
- });
53
-
54
- await client.disconnect();
55
- });
56
-
57
- describe("Login Tests", () => {
58
- test("should display login page", async () => {
59
- const testStart = Date.now();
60
-
61
- try {
62
- // Your test logic here
63
- await client.click("Login");
64
-
65
- // Record the test result
66
- await client.recordTestCase({
67
- runId,
68
- testName: "should display login page",
69
- testFile: "examples/test-recording-example.test.js",
70
- suiteName: "Login Tests",
71
- status: "passed",
72
- startTime: testStart,
73
- endTime: Date.now(),
74
- duration: Date.now() - testStart,
75
- });
76
- } catch (error) {
77
- // Record failure
78
- await client.recordTestCase({
79
- runId,
80
- testName: "should display login page",
81
- testFile: "examples/test-recording-example.test.js",
82
- status: "failed",
83
- errorMessage: error.message,
84
- errorStack: error.stack,
85
- });
86
- throw error;
87
- }
88
- });
89
-
90
- test("should login with valid credentials", async () => {
91
- const testStart = Date.now();
92
-
93
- try {
94
- // Test logic
95
- await client.type("username", "testuser");
96
- await client.type("password", "password123");
97
- await client.click("Submit");
98
-
99
- // Wait for dashboard
100
- await client.waitForText("Dashboard");
101
-
102
- // Record success
103
- await client.recordTestCase({
104
- runId,
105
- testName: "should login with valid credentials",
106
- testFile: "examples/test-recording-example.test.js",
107
- suiteName: "Login Tests",
108
- status: "passed",
109
- startTime: testStart,
110
- endTime: Date.now(),
111
- duration: Date.now() - testStart,
112
- // Associate with dashcam replay (if you have the URL)
113
- replayUrl: process.env.DASHCAM_REPLAY_URL,
114
- });
115
- } catch (error) {
116
- await client.recordTestCase({
117
- runId,
118
- testName: "should login with valid credentials",
119
- testFile: "examples/test-recording-example.test.js",
120
- status: "failed",
121
- errorMessage: error.message,
122
- errorStack: error.stack,
123
- });
124
- throw error;
125
- }
126
- });
127
-
128
- test("should show error with invalid credentials", async () => {
129
- const testStart = Date.now();
130
-
131
- try {
132
- await client.type("username", "wrong");
133
- await client.type("password", "wrong");
134
- await client.click("Submit");
135
-
136
- await client.waitForText("Invalid credentials");
137
-
138
- await client.recordTestCase({
139
- runId,
140
- testName: "should show error with invalid credentials",
141
- testFile: "examples/test-recording-example.test.js",
142
- suiteName: "Login Tests",
143
- status: "passed",
144
- startTime: testStart,
145
- endTime: Date.now(),
146
- duration: Date.now() - testStart,
147
- steps: [
148
- { action: "type", target: "username", value: "wrong" },
149
- { action: "type", target: "password", value: "wrong" },
150
- { action: "click", target: "Submit" },
151
- { action: "waitForText", target: "Invalid credentials" },
152
- ],
153
- });
154
- } catch (error) {
155
- await client.recordTestCase({
156
- runId,
157
- testName: "should show error with invalid credentials",
158
- testFile: "examples/test-recording-example.test.js",
159
- status: "failed",
160
- errorMessage: error.message,
161
- errorStack: error.stack,
162
- });
163
- throw error;
164
- }
165
- });
166
- });
@@ -1,57 +0,0 @@
1
- # TestDriver MCP Server - AI Agent Guidelines
2
-
3
- ## Essential Workflow
4
-
5
- 1. **Always connect first**: Call `testdriver_connect` before any other operations
6
- 2. **Verify with screenshots**: Screenshots are automatically captured after actions - review them to confirm success
7
- 3. **Wait before interacting**: Use `waitForText` or `waitForImage` before clicking/typing to ensure elements are ready
8
- 4. **Assert expectations**: After critical actions, use `assert` to verify the expected outcome
9
- 5. **Share debugger URL**: After connecting, share the debugger URL with users so they can watch in real-time
10
-
11
- ## Common Patterns
12
-
13
- ### Login Flow
14
-
15
- ```
16
- 1. connect() - start sandbox
17
- 2. getScreenshot() - see initial state
18
- 3. hoverText("Username") - click username field
19
- 4. type("user@example.com") - enter username
20
- 5. hoverText("Password") - click password field
21
- 6. type("password123") - enter password
22
- 7. hoverText("Login") - click login button
23
- 8. waitForText("Welcome") - wait for success
24
- 9. assert("the user is logged in") - verify outcome
25
- 10. getScreenshot() - capture final state
26
- ```
27
-
28
- ### Form Testing
29
-
30
- ```
31
- 1. Always wait for form elements before interacting
32
- 2. Take screenshots before and after form submission
33
- 3. Assert success/error messages appear
34
- 4. Use remember() to capture dynamic values (order IDs, timestamps, etc.)
35
- ```
36
-
37
- ## Best Practices
38
-
39
- - **Be patient**: Always wait for elements before clicking
40
- - **Be specific**: Use descriptive text in hoverText/assert (e.g., "the blue Submit button" not just "Submit")
41
- - **Verify everything**: Check screenshots to ensure actions succeeded
42
- - **Handle errors**: If an action fails, take a screenshot to diagnose
43
- - **Save tests**: Use `createTestFromActions` to save successful workflows
44
-
45
- ## Common Mistakes to Avoid
46
-
47
- ❌ Don't click elements that may not have loaded yet
48
- ✅ Do use `waitForText` first
49
-
50
- ❌ Don't assume actions succeeded without verification
51
- ✅ Do check screenshots and use assertions
52
-
53
- ❌ Don't chain many actions without pauses
54
- ✅ Do add small waits between rapid actions
55
-
56
- ❌ Don't forget to share the debugger URL
57
- ✅ Do tell users where to watch the live VM screen
package/test-find-api.js DELETED
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Quick test of the new find() API
5
- * This is a simple smoke test to verify the Element class works
6
- */
7
-
8
- const TestDriver = require("../sdk");
9
-
10
- async function testFindAPI() {
11
- console.log("Testing new find() API...\n");
12
-
13
- const client = new TestDriver("test-key", {
14
- logging: false,
15
- });
16
-
17
- // Test 1: Create element without connecting
18
- console.log("✓ Test 1: Creating Element instance");
19
- const element = client.find("test element");
20
- console.log(" Element description:", element.description);
21
- console.log(" Element found():", element.found());
22
- console.log(" Element coordinates:", element.getCoordinates());
23
-
24
- // Test 2: Verify element methods exist
25
- console.log("\n✓ Test 2: Verifying Element methods");
26
- console.log(" Has find():", typeof element.find === "function");
27
- console.log(" Has click():", typeof element.click === "function");
28
- console.log(" Has hover():", typeof element.hover === "function");
29
- console.log(
30
- " Has doubleClick():",
31
- typeof element.doubleClick === "function",
32
- );
33
- console.log(" Has rightClick():", typeof element.rightClick === "function");
34
- console.log(" Has mouseDown():", typeof element.mouseDown === "function");
35
- console.log(" Has mouseUp():", typeof element.mouseUp === "function");
36
- console.log(" Has found():", typeof element.found === "function");
37
- console.log(
38
- " Has getCoordinates():",
39
- typeof element.getCoordinates === "function",
40
- );
41
-
42
- // Test 3: Verify error handling for clicking unfound element
43
- console.log("\n✓ Test 3: Error handling for unfound element");
44
- try {
45
- await element.click();
46
- console.log(" ❌ Should have thrown error");
47
- } catch (error) {
48
- console.log(" ✓ Correctly throws error:", error.message);
49
- }
50
-
51
- // Test 4: Verify TypeScript types exist (if running from TypeScript)
52
- console.log("\n✓ Test 4: SDK methods");
53
- console.log(" Has find():", typeof client.find === "function");
54
- console.log(
55
- " Has deprecated hoverText():",
56
- typeof client.hoverText === "undefined" ? "not yet connected" : "exists",
57
- );
58
- console.log(
59
- " Has deprecated waitForText():",
60
- typeof client.waitForText === "undefined" ? "not yet connected" : "exists",
61
- );
62
-
63
- console.log("\n✅ All basic tests passed!");
64
- console.log(
65
- "\nNote: Full integration tests require connection to TestDriver sandbox.",
66
- );
67
- console.log("See examples/sdk-find-example.js for complete usage examples.");
68
- }
69
-
70
- testFindAPI().catch((error) => {
71
- console.error("Test failed:", error);
72
- process.exit(1);
73
- });
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Simple test to verify prompt caching functionality
5
- *
6
- * This test demonstrates that:
7
- * 1. First .prompt() call makes an API request and caches the YAML response
8
- * 2. Second .prompt() call with the same prompt uses the cached YAML
9
- * 3. Cache can be disabled with TD_NO_PROMPT_CACHE=true
10
- */
11
-
12
- const TestDriver = require("./sdk.js");
13
- const promptCache = require("./agent/lib/cache.js");
14
-
15
- async function testPromptCache() {
16
- console.log("Testing prompt caching functionality...\n");
17
-
18
- const client = new TestDriver(process.env.TD_API_KEY, {
19
- os: "linux",
20
- logging: true,
21
- });
22
-
23
- try {
24
- // Connect to sandbox
25
- console.log("Connecting to sandbox...");
26
- await client.connect();
27
- console.log("Connected!\n");
28
-
29
- const testPrompt = "click the search button";
30
-
31
- // Clear cache for this prompt to start fresh
32
- const cachePath = promptCache.getCachePath(testPrompt);
33
- console.log(`Cache path for "${testPrompt}": ${cachePath}\n`);
34
-
35
- // Test 1: First call (should make API request and cache)
36
- console.log("Test 1: First .ai() call (should cache the response)");
37
- const stats1 = promptCache.getCacheStats();
38
- console.log(`Cache before: ${stats1.count} files`);
39
-
40
- await client.ai(testPrompt);
41
-
42
- const stats2 = promptCache.getCacheStats();
43
- console.log(`Cache after: ${stats2.count} files`);
44
- console.log(
45
- `Cache hit: ${promptCache.hasCache(testPrompt) ? "YES" : "NO"}\n`,
46
- );
47
-
48
- // Test 2: Second call (should use cache)
49
- console.log(
50
- "Test 2: Second .ai() call with same prompt (should use cache)",
51
- );
52
- console.log('Look for "(using cached response)" message above...\n');
53
- await client.ai(testPrompt);
54
-
55
- // Test 3: Third call with cache disabled (should make API call)
56
- console.log(
57
- "\nTest 3: Third .ai() call with cache=false (should bypass cache)",
58
- );
59
- await client.ai(testPrompt, false);
60
-
61
- // Test 4: Show cache contents
62
- console.log("\nTest 4: Cache contents");
63
- const cachedYaml = promptCache.readCache(testPrompt);
64
- if (cachedYaml) {
65
- console.log("Cached YAML preview (first 500 chars):");
66
- console.log(cachedYaml.substring(0, 500));
67
- console.log("...\n");
68
- }
69
-
70
- // Test 5: Cache statistics
71
- console.log("Test 5: Cache statistics");
72
- const finalStats = promptCache.getCacheStats();
73
- console.log(`Total cached prompts: ${finalStats.count}`);
74
- console.log(`Cache files:`, finalStats.files.slice(0, 5));
75
-
76
- console.log("\n✅ Prompt caching test completed!");
77
- console.log("\nTo disable caching, pass false: client.ai(prompt, false)");
78
- console.log("To clear cache, delete .testdriver/.cache/*.yaml files");
79
- } catch (error) {
80
- console.error("❌ Test failed:", error.message);
81
- throw error;
82
- } finally {
83
- // Disconnect
84
- await client.disconnect();
85
- }
86
- }
87
-
88
- // Run the test
89
- if (require.main === module) {
90
- testPromptCache().catch((error) => {
91
- console.error("Test error:", error);
92
- process.exit(1);
93
- });
94
- }
95
-
96
- module.exports = testPromptCache;
@@ -1,28 +0,0 @@
1
- const TestDriver = require("./sdk.js");
2
-
3
- async function test() {
4
- console.log("Testing sandbox rendering...");
5
-
6
- const client = new TestDriver(process.env.TD_API_KEY, {
7
- os: process.env.TEST_PLATFORM || "linux",
8
- headless: false, // Should open browser
9
- logging: true,
10
- });
11
-
12
- try {
13
- console.log("Connecting to sandbox...");
14
- const instance = await client.connect();
15
- console.log("Connected to instance:", instance);
16
-
17
- // Wait a bit to see if browser opens
18
- await new Promise((resolve) => setTimeout(resolve, 5000));
19
-
20
- await client.disconnect();
21
- console.log("Test completed successfully");
22
- } catch (error) {
23
- console.error("Test failed:", error);
24
- process.exit(1);
25
- }
26
- }
27
-
28
- test();
@@ -1,15 +0,0 @@
1
- const SDK = require("./sdk.js");
2
-
3
- const client = new SDK("test-key");
4
-
5
- // Get all public methods (non-private, non-constructor)
6
- const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(client))
7
- .filter((m) => !m.startsWith("_") && m !== "constructor")
8
- .sort();
9
-
10
- console.log("Public SDK Methods:");
11
- console.log(methods.join(", "));
12
- console.log("\nTotal:", methods.length, "methods");
13
-
14
- // Check if commands will be set up after connect
15
- console.log("\nCommands before connect:", client.commands);
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Quick test to verify SDK refactoring works correctly
5
- */
6
-
7
- const TestDriver = require("./sdk.js");
8
-
9
- async function test() {
10
- console.log("Testing SDK refactor...\n");
11
-
12
- // Test 1: SDK construction
13
- console.log("✓ Test 1: Creating SDK instance");
14
- const client = new TestDriver(process.env.TD_API_KEY || "test-key", {
15
- logging: false,
16
- });
17
-
18
- console.log(" - agent exists:", !!client.agent);
19
- console.log(" - emitter exists:", !!client.emitter);
20
- console.log(" - config exists:", !!client.config);
21
- console.log(" - session exists:", !!client.session);
22
- console.log(" - apiClient exists:", !!client.apiClient);
23
- console.log(" - analytics exists:", !!client.analytics);
24
- console.log(" - sandbox exists:", !!client.sandbox);
25
- console.log(" - system exists:", !!client.system);
26
-
27
- // Test 2: Check agent methods are accessible
28
- console.log("\n✓ Test 2: Checking agent methods");
29
- console.log(
30
- " - agent.exploratoryLoop exists:",
31
- typeof client.agent.exploratoryLoop,
32
- );
33
- console.log(" - agent.buildEnv exists:", typeof client.agent.buildEnv);
34
- console.log(
35
- " - agent.getRecentSandboxId exists:",
36
- typeof client.agent.getRecentSandboxId,
37
- );
38
-
39
- // Test 3: Check SDK methods
40
- console.log("\n✓ Test 3: Checking SDK methods");
41
- console.log(" - ai() exists:", typeof client.ai);
42
- console.log(" - auth() exists:", typeof client.auth);
43
- console.log(" - connect() exists:", typeof client.connect);
44
- console.log(" - disconnect() exists:", typeof client.disconnect);
45
-
46
- console.log("\n✅ All basic tests passed!");
47
- }
48
-
49
- test().catch((error) => {
50
- console.error("\n❌ Test failed:", error.message);
51
- console.error(error.stack);
52
- process.exit(1);
53
- });
@@ -1,57 +0,0 @@
1
- /**
2
- * Quick test to verify stack trace filtering works
3
- */
4
-
5
- // Mock the MatchError similar to commands.js
6
- class MatchError extends Error {
7
- constructor(message, fatal = false) {
8
- super(message);
9
- this.fatal = fatal;
10
- this.attachScreenshot = true;
11
- }
12
- }
13
-
14
- // Simulate SDK wrapper with stack filtering (improved version)
15
- class TestSDK {
16
- constructor() {
17
- const command = async (message) => {
18
- // Simulate the command throwing an error
19
- throw new MatchError(`AI Assertion failed: ${message}`, true);
20
- };
21
-
22
- // Wrap the method with proper stack trace handling
23
- this.assert = async function (...args) {
24
- // Capture the call site for better error reporting
25
- const callSite = {};
26
- Error.captureStackTrace(callSite, this.assert);
27
-
28
- try {
29
- return await command(...args);
30
- } catch (error) {
31
- // Replace the stack trace to point to the actual caller
32
- if (Error.captureStackTrace && callSite.stack) {
33
- const errorMessage = error.stack?.split("\n")[0];
34
- const callerStack = callSite.stack?.split("\n").slice(1);
35
- error.stack = errorMessage + "\n" + callerStack.join("\n");
36
- }
37
- throw error;
38
- }
39
- }.bind(this);
40
- }
41
- }
42
-
43
- // Test it
44
- async function runTest() {
45
- const client = new TestSDK();
46
-
47
- try {
48
- console.log("Testing stack trace...\n");
49
- await client.assert("home page appears"); // Line 42 - this should show in stack
50
- } catch (error) {
51
- console.log("Error caught!");
52
- console.log("Stack trace:");
53
- console.log(error.stack);
54
- }
55
- }
56
-
57
- runTest();