testdriverai 7.2.74 → 7.2.75

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.
@@ -2,7 +2,6 @@
2
2
  name: testdriver
3
3
  description: An expert at creating and refining automated tests using TestDriver.ai
4
4
  tools:
5
- - testdriver/*
6
5
  mcp-servers:
7
6
  testdriver:
8
7
  command: npx
@@ -356,11 +356,8 @@ test('should login and add item to cart', async (context) => {
356
356
  if (!fs.existsSync(configFile)) {
357
357
  const configContent = `import { defineConfig } from 'vitest/config';
358
358
  import TestDriver from 'testdriverai/vitest';
359
- import { config } from 'dotenv';
360
-
361
- // Load environment variables from .env file
362
- config();
363
359
 
360
+ // Note: dotenv is loaded automatically by the TestDriver SDK
364
361
  export default defineConfig({
365
362
  test: {
366
363
  testTimeout: 300000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.2.74",
3
+ "version": "7.2.75",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
package/sdk.d.ts CHANGED
@@ -867,7 +867,22 @@ export interface DashcamAPI {
867
867
  }
868
868
 
869
869
  export default class TestDriverSDK {
870
- constructor(apiKey: string, options?: TestDriverOptions);
870
+ /**
871
+ * Create a new TestDriverSDK instance
872
+ * Automatically loads environment variables from .env file via dotenv.
873
+ *
874
+ * @param apiKey - API key (optional, defaults to TD_API_KEY environment variable)
875
+ * @param options - SDK configuration options
876
+ *
877
+ * @example
878
+ * // API key loaded automatically from TD_API_KEY in .env
879
+ * const client = new TestDriver();
880
+ *
881
+ * @example
882
+ * // Or pass API key explicitly
883
+ * const client = new TestDriver('your-api-key');
884
+ */
885
+ constructor(apiKey?: string, options?: TestDriverOptions);
871
886
 
872
887
  /**
873
888
  * Whether the SDK is currently connected to a sandbox
package/sdk.js CHANGED
@@ -5,6 +5,9 @@ const crypto = require("crypto");
5
5
  const { formatter } = require("./sdk-log-formatter");
6
6
  const logger = require("./agent/lib/logger");
7
7
 
8
+ // Load .env file into process.env by default
9
+ require("dotenv").config();
10
+
8
11
  /**
9
12
  * Get the file path of the caller (the file that called TestDriver)
10
13
  * @returns {string|null} File path or null if not found
@@ -1233,13 +1236,18 @@ function createChainablePromise(promise) {
1233
1236
  * TestDriver SDK
1234
1237
  *
1235
1238
  * This SDK provides programmatic access to TestDriver's AI-powered testing capabilities.
1239
+ * Automatically loads environment variables from .env file via dotenv.
1236
1240
  *
1237
1241
  * @example
1238
1242
  * const TestDriver = require('testdriverai');
1239
1243
  *
1240
- * const client = new TestDriver(process.env.TD_API_KEY);
1244
+ * // API key loaded automatically from TD_API_KEY in .env
1245
+ * const client = new TestDriver();
1241
1246
  * await client.connect();
1242
1247
  *
1248
+ * // Or pass API key explicitly
1249
+ * const client = new TestDriver('your-api-key');
1250
+ *
1243
1251
  * // New API
1244
1252
  * const element = await client.find('Submit button');
1245
1253
  * await element.click();
@@ -1264,9 +1272,18 @@ const { createMarkdownLogger } = require("./interfaces/logger.js");
1264
1272
 
1265
1273
  class TestDriverSDK {
1266
1274
  constructor(apiKey, options = {}) {
1275
+ // Support calling with just options: new TestDriver({ os: 'windows' })
1276
+ if (typeof apiKey === 'object' && apiKey !== null) {
1277
+ options = apiKey;
1278
+ apiKey = null;
1279
+ }
1280
+
1281
+ // Use provided API key or fall back to environment variable
1282
+ const resolvedApiKey = apiKey || process.env.TD_API_KEY;
1283
+
1267
1284
  // Set up environment with API key
1268
1285
  const environment = {
1269
- TD_API_KEY: apiKey,
1286
+ TD_API_KEY: resolvedApiKey,
1270
1287
  TD_API_ROOT: options.apiRoot || "https://testdriver-api.onrender.com",
1271
1288
  TD_RESOLUTION: options.resolution || "1366x768",
1272
1289
  TD_ANALYTICS: options.analytics !== false,