testdriverai 7.2.21 → 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.
@@ -142,11 +142,9 @@ export default defineConfig({
142
142
 
143
143
  ### Test Helpers
144
144
 
145
- - ✅ **Updated**: `testdriver/acceptance-sdk/setup/testHelpers.mjs`
146
- - Removed temp file writing
147
- - Removed `__testdriverRegistry` initialization
148
- - Removed `__testdriverMeta` initialization
149
- - Uses `globalThis.__testdriverPlugin.registerDashcamUrl()` instead
145
+ - ✅ **Removed**: `test/testdriver/setup/` folder (legacy helpers)
146
+ - Code moved to `lib/vitest/hooks.mjs` framework
147
+ - Tests now use `TestDriver(context, options)` pattern directly
150
148
 
151
149
  ### Documentation
152
150
 
@@ -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
- // Set test metadata directly on the Vitest task context
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.2.21",
3
+ "version": "7.2.23",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "exports": {
@@ -5,7 +5,25 @@
5
5
 
6
6
  import { describe, expect, it } from "vitest";
7
7
  import { TestDriver } from "../../lib/vitest/hooks.mjs";
8
- import { performLogin } from "./setup/testHelpers.mjs";
8
+
9
+ /**
10
+ * Perform login flow for SauceLabs demo app
11
+ * @param {TestDriver} client - TestDriver client
12
+ * @param {string} username - Username (default: 'standard_user')
13
+ */
14
+ async function performLogin(client, username = "standard_user") {
15
+ await client.focusApplication("Google Chrome");
16
+ const password = await client.extract("the password");
17
+ const usernameField = await client.find(
18
+ "Username, label above the username input field on the login form",
19
+ );
20
+ await usernameField.click();
21
+ await client.type(username);
22
+ await client.pressKeys(["tab"]);
23
+ await client.type(password, { secret: true });
24
+ await client.pressKeys(["tab"]);
25
+ await client.pressKeys(["enter"]);
26
+ }
9
27
 
10
28
  describe("Hover Image Test", () => {
11
29
  it("should click on shopping cart icon and verify empty cart", async (context) => {
@@ -5,7 +5,25 @@
5
5
 
6
6
  import { describe, expect, it } from "vitest";
7
7
  import { TestDriver } from "../../lib/vitest/hooks.mjs";
8
- import { performLogin } from "./setup/testHelpers.mjs";
8
+
9
+ /**
10
+ * Perform login flow for SauceLabs demo app
11
+ * @param {TestDriver} client - TestDriver client
12
+ * @param {string} username - Username (default: 'standard_user')
13
+ */
14
+ async function performLogin(client, username = "standard_user") {
15
+ await client.focusApplication("Google Chrome");
16
+ const password = await client.extract("the password");
17
+ const usernameField = await client.find(
18
+ "Username, label above the username input field on the login form",
19
+ );
20
+ await usernameField.click();
21
+ await client.type(username);
22
+ await client.pressKeys(["tab"]);
23
+ await client.type(password, { secret: true });
24
+ await client.pressKeys(["tab"]);
25
+ await client.pressKeys(["enter"]);
26
+ }
9
27
 
10
28
  describe("Hover Text With Description Test", () => {
11
29
  it("should add TestDriver Hat to cart and verify", async (context) => {
@@ -7,7 +7,25 @@ import path, { dirname } from "path";
7
7
  import { fileURLToPath } from "url";
8
8
  import { describe, expect, it } from "vitest";
9
9
  import { TestDriver } from "../../lib/vitest/hooks.mjs";
10
- import { performLogin } from "./setup/testHelpers.mjs";
10
+
11
+ /**
12
+ * Perform login flow for SauceLabs demo app
13
+ * @param {TestDriver} client - TestDriver client
14
+ * @param {string} username - Username (default: 'standard_user')
15
+ */
16
+ async function performLogin(client, username = "standard_user") {
17
+ await client.focusApplication("Google Chrome");
18
+ const password = await client.extract("the password");
19
+ const usernameField = await client.find(
20
+ "Username, label above the username input field on the login form",
21
+ );
22
+ await usernameField.click();
23
+ await client.type(username);
24
+ await client.pressKeys(["tab"]);
25
+ await client.type(password, { secret: true });
26
+ await client.pressKeys(["tab"]);
27
+ await client.pressKeys(["enter"]);
28
+ }
11
29
 
12
30
  // Get the directory of the current module
13
31
  const __filename = fileURLToPath(import.meta.url);
@@ -5,7 +5,25 @@
5
5
 
6
6
  import { describe, expect, it } from "vitest";
7
7
  import { TestDriver } from "../../lib/vitest/hooks.mjs";
8
- import { performLogin } from "./setup/testHelpers.mjs";
8
+
9
+ /**
10
+ * Perform login flow for SauceLabs demo app
11
+ * @param {TestDriver} client - TestDriver client
12
+ * @param {string} username - Username (default: 'standard_user')
13
+ */
14
+ async function performLogin(client, username = "standard_user") {
15
+ await client.focusApplication("Google Chrome");
16
+ const password = await client.extract("the password");
17
+ const usernameField = await client.find(
18
+ "Username, label above the username input field on the login form",
19
+ );
20
+ await usernameField.click();
21
+ await client.type(username);
22
+ await client.pressKeys(["tab"]);
23
+ await client.type(password, { secret: true });
24
+ await client.pressKeys(["tab"]);
25
+ await client.pressKeys(["enter"]);
26
+ }
9
27
 
10
28
  describe("Scroll Until Text Test", () => {
11
29
  it('should scroll until "testdriver socks" appears', async (context) => {