testdriverai 7.3.1 → 7.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/index.js +32 -3
- package/lib/vitest/hooks.mjs +3 -0
- package/package.json +1 -1
- package/sdk.js +3 -0
package/agent/index.js
CHANGED
|
@@ -2046,12 +2046,13 @@ ${regression}
|
|
|
2046
2046
|
// Use the debugger URL instead of the VNC URL
|
|
2047
2047
|
const urlToOpen = `${this.debuggerUrl}?data=${encodedData}`;
|
|
2048
2048
|
|
|
2049
|
-
// Check preview mode from
|
|
2050
|
-
const previewMode = this.config.TD_PREVIEW || "browser";
|
|
2049
|
+
// Check preview mode from CLI options (SDK passes it directly)
|
|
2050
|
+
const previewMode = (this.cliArgs.options && this.cliArgs.options.preview) || this.config.TD_PREVIEW || "browser";
|
|
2051
|
+
console.log("[DEBUG renderSandbox] preview:", previewMode);
|
|
2051
2052
|
|
|
2052
2053
|
if (previewMode === "ide") {
|
|
2053
2054
|
// Send session to VS Code extension via HTTP
|
|
2054
|
-
this.
|
|
2055
|
+
this.writeIdeSessionFile(urlToOpen, data);
|
|
2055
2056
|
} else if (previewMode !== "none") {
|
|
2056
2057
|
// Open in browser (default behavior)
|
|
2057
2058
|
this.emitter.emit(events.showWindow, urlToOpen);
|
|
@@ -2060,6 +2061,34 @@ ${regression}
|
|
|
2060
2061
|
}
|
|
2061
2062
|
}
|
|
2062
2063
|
|
|
2064
|
+
// Write session file for IDE preview (VSCode extension watches for these)
|
|
2065
|
+
writeIdeSessionFile(debuggerUrl, data) {
|
|
2066
|
+
const fs = require("fs");
|
|
2067
|
+
const path = require("path");
|
|
2068
|
+
|
|
2069
|
+
const sessionId = `${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
2070
|
+
const previewsDir = path.join(process.cwd(), ".testdriver", ".previews");
|
|
2071
|
+
|
|
2072
|
+
// Create the previews directory if it doesn't exist
|
|
2073
|
+
if (!fs.existsSync(previewsDir)) {
|
|
2074
|
+
fs.mkdirSync(previewsDir, { recursive: true });
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
const sessionData = {
|
|
2078
|
+
sessionId,
|
|
2079
|
+
debuggerUrl,
|
|
2080
|
+
resolution: Array.isArray(data.resolution) ? data.resolution : (data.resolution ? data.resolution.split("x").map(Number) : [1920, 1080]),
|
|
2081
|
+
testFile: data.testFile || this.testFile || null,
|
|
2082
|
+
os: data.os || this.sandboxOs || "linux",
|
|
2083
|
+
timestamp: Date.now(),
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
const filePath = path.join(previewsDir, `${sessionId}.json`);
|
|
2087
|
+
fs.writeFileSync(filePath, JSON.stringify(sessionData, null, 2));
|
|
2088
|
+
|
|
2089
|
+
logger.log(`IDE preview session written to ${filePath}`);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2063
2092
|
// Find the VS Code instance that contains the test file
|
|
2064
2093
|
findTargetIdeInstance(testFilePath) {
|
|
2065
2094
|
const fs = require("fs");
|
package/lib/vitest/hooks.mjs
CHANGED
|
@@ -191,6 +191,7 @@ const lifecycleHandlers = new WeakMap();
|
|
|
191
191
|
* });
|
|
192
192
|
*/
|
|
193
193
|
export function TestDriver(context, options = {}) {
|
|
194
|
+
console.log("[DEBUG hooks entry] options:", JSON.stringify(options));
|
|
194
195
|
if (!context || !context.task) {
|
|
195
196
|
throw new Error(
|
|
196
197
|
'TestDriver() requires Vitest context. Pass the context parameter from your test function: test("name", async (context) => { ... })',
|
|
@@ -246,6 +247,8 @@ export function TestDriver(context, options = {}) {
|
|
|
246
247
|
config.apiRoot = process.env.TD_API_ROOT;
|
|
247
248
|
}
|
|
248
249
|
|
|
250
|
+
console.log("[DEBUG hooks] options.preview:", options.preview, "config.preview:", config.preview);
|
|
251
|
+
|
|
249
252
|
const testdriver = new TestDriverSDK(apiKey, config);
|
|
250
253
|
testdriver.__vitestContext = context.task;
|
|
251
254
|
testdriver._debugOnFailure = mergedOptions.debugOnFailure || false;
|
package/package.json
CHANGED
package/sdk.js
CHANGED
|
@@ -1329,6 +1329,7 @@ class TestDriverSDK {
|
|
|
1329
1329
|
// Handle preview mode with backwards compatibility for headless option
|
|
1330
1330
|
// Preview can be "browser" (default), "ide", or "none" (headless)
|
|
1331
1331
|
let previewMode = options.preview || process.env.TD_PREVIEW;
|
|
1332
|
+
console.log("[DEBUG SDK constructor] options.preview:", options.preview, "previewMode:", previewMode);
|
|
1332
1333
|
|
|
1333
1334
|
// Backwards compatibility: headless: true maps to preview: "none"
|
|
1334
1335
|
if (options.headless === true && !options.preview) {
|
|
@@ -1336,6 +1337,7 @@ class TestDriverSDK {
|
|
|
1336
1337
|
} else if (!previewMode) {
|
|
1337
1338
|
previewMode = "browser"; // default
|
|
1338
1339
|
}
|
|
1340
|
+
console.log("[DEBUG SDK constructor] final previewMode:", previewMode);
|
|
1339
1341
|
|
|
1340
1342
|
// Set up environment with API key
|
|
1341
1343
|
const environment = {
|
|
@@ -1353,6 +1355,7 @@ class TestDriverSDK {
|
|
|
1353
1355
|
args: [],
|
|
1354
1356
|
options: {
|
|
1355
1357
|
os: options.os || "linux",
|
|
1358
|
+
preview: previewMode,
|
|
1356
1359
|
},
|
|
1357
1360
|
});
|
|
1358
1361
|
|