testdriverai 7.2.22 → 7.2.23
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/lib/vitest/hooks.mjs +26 -14
- package/package.json +1 -1
package/lib/vitest/hooks.mjs
CHANGED
|
@@ -286,6 +286,26 @@ export function TestDriver(context, options = {}) {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
try {
|
|
289
|
+
// Ensure meta object exists
|
|
290
|
+
if (!context.task.meta) {
|
|
291
|
+
context.task.meta = {};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Always set test metadata, even if dashcam never started or fails to stop
|
|
295
|
+
// This ensures the reporter can record test results even for early failures
|
|
296
|
+
const platform = currentInstance.os || 'linux';
|
|
297
|
+
const absolutePath = context.task.file?.filepath || context.task.file?.name || 'unknown';
|
|
298
|
+
const projectRoot = process.cwd();
|
|
299
|
+
const testFile = absolutePath !== 'unknown'
|
|
300
|
+
? path.relative(projectRoot, absolutePath)
|
|
301
|
+
: absolutePath;
|
|
302
|
+
|
|
303
|
+
// Set basic metadata that's always available
|
|
304
|
+
context.task.meta.platform = platform;
|
|
305
|
+
context.task.meta.testFile = testFile;
|
|
306
|
+
context.task.meta.testOrder = 0;
|
|
307
|
+
context.task.meta.sessionId = currentInstance.getSessionId?.() || null;
|
|
308
|
+
|
|
289
309
|
// Stop dashcam if it was started - with timeout to prevent hanging
|
|
290
310
|
if (currentInstance._dashcam && currentInstance._dashcam.recording) {
|
|
291
311
|
try {
|
|
@@ -294,21 +314,8 @@ export function TestDriver(context, options = {}) {
|
|
|
294
314
|
console.log('🎥' + chalk.yellow(` Dashcam URL`) + `: ${dashcamUrl}`);
|
|
295
315
|
console.log('');
|
|
296
316
|
|
|
297
|
-
//
|
|
298
|
-
// This is the proper way to pass data from test to reporter
|
|
299
|
-
const platform = currentInstance.os || 'linux';
|
|
300
|
-
const absolutePath = context.task.file?.filepath || context.task.file?.name || 'unknown';
|
|
301
|
-
const projectRoot = process.cwd();
|
|
302
|
-
const testFile = absolutePath !== 'unknown'
|
|
303
|
-
? path.relative(projectRoot, absolutePath)
|
|
304
|
-
: absolutePath;
|
|
305
|
-
|
|
306
|
-
// Set metadata on the task for the reporter to read
|
|
317
|
+
// Add dashcam URL to metadata
|
|
307
318
|
context.task.meta.dashcamUrl = dashcamUrl || null;
|
|
308
|
-
context.task.meta.platform = platform;
|
|
309
|
-
context.task.meta.testFile = testFile;
|
|
310
|
-
context.task.meta.testOrder = 0;
|
|
311
|
-
context.task.meta.sessionId = currentInstance.getSessionId();
|
|
312
319
|
|
|
313
320
|
// Also register in memory if plugin is available (for cross-process scenarios)
|
|
314
321
|
if (globalThis.__testdriverPlugin?.registerDashcamUrl) {
|
|
@@ -326,7 +333,12 @@ export function TestDriver(context, options = {}) {
|
|
|
326
333
|
if (currentInstance._dashcam) {
|
|
327
334
|
currentInstance._dashcam.recording = false;
|
|
328
335
|
}
|
|
336
|
+
// Ensure dashcamUrl is set to null if stop failed
|
|
337
|
+
context.task.meta.dashcamUrl = null;
|
|
329
338
|
}
|
|
339
|
+
} else {
|
|
340
|
+
// No dashcam recording, set URL to null explicitly
|
|
341
|
+
context.task.meta.dashcamUrl = null;
|
|
330
342
|
}
|
|
331
343
|
|
|
332
344
|
// Clean up console spies
|