testdriverai 7.2.3 → 7.2.10

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 (142) hide show
  1. package/.github/workflows/publish.yaml +15 -7
  2. package/.github/workflows/testdriver.yml +163 -0
  3. package/.testdriver/last-sandbox +7 -0
  4. package/agent/events.js +1 -0
  5. package/agent/index.js +99 -163
  6. package/agent/lib/sandbox.js +11 -1
  7. package/agents.md +393 -0
  8. package/bin/testdriverai.js +8 -0
  9. package/debug/01-table-initial.png +0 -0
  10. package/debug/02-after-ai-explore.png +0 -0
  11. package/debug/02-after-scroll.png +0 -0
  12. package/debugger/index.html +37 -0
  13. package/docs/docs.json +93 -125
  14. package/docs/v7/_drafts/architecture.mdx +1 -26
  15. package/docs/v7/_drafts/caching.mdx +2 -2
  16. package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
  17. package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
  18. package/docs/v7/_drafts/quick-start-test-recording.mdx +0 -1
  19. package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
  20. package/docs/v7/_drafts/screenshot.mdx +155 -0
  21. package/docs/v7/_drafts/test-recording.mdx +0 -6
  22. package/docs/v7/_drafts/writing-tests.mdx +25 -0
  23. package/docs/v7/{api/act.mdx → ai.mdx} +28 -27
  24. package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
  25. package/docs/v7/aws-setup.mdx +338 -0
  26. package/docs/v7/caching.mdx +128 -0
  27. package/docs/v7/ci-cd.mdx +605 -0
  28. package/docs/v7/{api/click.mdx → click.mdx} +4 -4
  29. package/docs/v7/cloud.mdx +120 -0
  30. package/docs/v7/customizing-devices.mdx +129 -0
  31. package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
  32. package/docs/v7/enterprise.mdx +135 -0
  33. package/docs/v7/examples.mdx +5 -0
  34. package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
  35. package/docs/v7/{api/find.mdx → find.mdx} +17 -21
  36. package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
  37. package/docs/v7/generating-tests.mdx +32 -0
  38. package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
  39. package/docs/v7/locating-elements.mdx +71 -0
  40. package/docs/v7/making-assertions.mdx +32 -0
  41. package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
  42. package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
  43. package/docs/v7/performing-actions.mdx +51 -0
  44. package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
  45. package/docs/v7/quickstart.mdx +162 -0
  46. package/docs/v7/reusable-code.mdx +240 -0
  47. package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
  48. package/docs/v7/running-tests.mdx +181 -0
  49. package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
  50. package/docs/v7/secrets.mdx +115 -0
  51. package/docs/v7/self-hosted.mdx +66 -0
  52. package/docs/v7/{api/type.mdx → type.mdx} +3 -3
  53. package/docs/v7/variables.mdx +111 -0
  54. package/docs/v7/waiting-for-elements.mdx +66 -0
  55. package/docs/v7/what-is-testdriver.mdx +54 -0
  56. package/interfaces/cli/commands/init.js +33 -19
  57. package/interfaces/cli/lib/base.js +24 -0
  58. package/interfaces/cli.js +8 -1
  59. package/interfaces/logger.js +8 -3
  60. package/interfaces/vitest-plugin.mjs +16 -71
  61. package/lib/sentry.js +343 -0
  62. package/lib/vitest/hooks.mjs +81 -81
  63. package/package.json +4 -3
  64. package/sdk-log-formatter.js +41 -0
  65. package/sdk.d.ts +22 -9
  66. package/sdk.js +344 -100
  67. package/test/manual/reconnect-provision.test.mjs +49 -0
  68. package/test/manual/reconnect-signin.test.mjs +41 -0
  69. package/test/testdriver/act.test.mjs +30 -0
  70. package/test/testdriver/ai.test.mjs +30 -0
  71. package/test/testdriver/assert.test.mjs +1 -1
  72. package/test/testdriver/hover-text.test.mjs +1 -1
  73. package/test/testdriver/setup/testHelpers.mjs +8 -119
  74. package/test/testdriver/windows-installer.test.mjs +61 -0
  75. package/tests/example.test.js +33 -0
  76. package/tests/login.js +28 -0
  77. package/tests/table-sort-enrollments.test.mjs +72 -0
  78. package/tests/table-sort-experiment.test.mjs +42 -0
  79. package/tests/table-sort-setup.test.mjs +59 -0
  80. package/vitest.config.mjs +3 -1
  81. package/agent/lib/cache.js +0 -142
  82. package/docs/v7/api/assertions.mdx +0 -403
  83. package/docs/v7/features/ai-native.mdx +0 -413
  84. package/docs/v7/features/application-logs.mdx +0 -353
  85. package/docs/v7/features/browser-logs.mdx +0 -414
  86. package/docs/v7/features/cache-management.mdx +0 -402
  87. package/docs/v7/features/continuous-testing.mdx +0 -346
  88. package/docs/v7/features/data-driven-testing.mdx +0 -441
  89. package/docs/v7/features/easy-to-write.mdx +0 -280
  90. package/docs/v7/features/enterprise.mdx +0 -656
  91. package/docs/v7/features/fast.mdx +0 -406
  92. package/docs/v7/features/managed-sandboxes.mdx +0 -384
  93. package/docs/v7/features/network-monitoring.mdx +0 -568
  94. package/docs/v7/features/parallel-execution.mdx +0 -381
  95. package/docs/v7/features/powerful.mdx +0 -531
  96. package/docs/v7/features/sandbox-customization.mdx +0 -229
  97. package/docs/v7/features/stable.mdx +0 -473
  98. package/docs/v7/features/system-performance.mdx +0 -616
  99. package/docs/v7/features/test-analytics.mdx +0 -373
  100. package/docs/v7/features/test-cases.mdx +0 -393
  101. package/docs/v7/features/test-replays.mdx +0 -408
  102. package/docs/v7/features/test-reports.mdx +0 -308
  103. package/docs/v7/getting-started/debugging-tests.mdx +0 -382
  104. package/docs/v7/getting-started/quickstart.mdx +0 -90
  105. package/docs/v7/getting-started/running-tests.mdx +0 -173
  106. package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
  107. package/docs/v7/getting-started/writing-tests.mdx +0 -534
  108. package/docs/v7/overview/what-is-testdriver.mdx +0 -386
  109. package/docs/v7/presets/chrome-extension.mdx +0 -248
  110. package/docs/v7/presets/chrome.mdx +0 -300
  111. package/docs/v7/presets/electron.mdx +0 -460
  112. package/docs/v7/presets/vscode.mdx +0 -417
  113. package/docs/v7/presets/webapp.mdx +0 -393
  114. /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
  115. /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
  116. /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
  117. /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
  118. /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
  119. /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
  120. /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
  121. /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
  122. /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
  123. /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
  124. /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
  125. /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
  126. /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
  127. /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
  128. /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
  129. /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
  130. /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
  131. /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
  132. /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
  133. /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
  134. /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
  135. /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
  136. /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
  137. /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
  138. /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
  139. /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
  140. /package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -0
  141. /package/docs/v7/{api/elements.mdx → elements.mdx} +0 -0
  142. /package/docs/v7/{api/sandbox.mdx → sandbox.mdx} +0 -0
@@ -878,6 +878,47 @@ class SDKLogFormatter {
878
878
 
879
879
  return `\n${parts.join(" ")}\n`;
880
880
  }
881
+
882
+ /**
883
+ * Format act() start message - provides visual scope boundary
884
+ * @param {string} task - The task being executed
885
+ * @returns {string} Formatted act start message
886
+ */
887
+ formatActStart(task) {
888
+ const parts = [];
889
+ this.addTimestamp(parts);
890
+ parts.push(this.getPrefix("action"));
891
+ parts.push(chalk.bold.cyan("Act"));
892
+ parts.push(chalk.cyan(`"${task}"`));
893
+ return parts.join(" ");
894
+ }
895
+
896
+ /**
897
+ * Format act() completion message - provides visual scope boundary
898
+ * @param {number} durationMs - Duration in milliseconds
899
+ * @param {boolean} success - Whether the act completed successfully
900
+ * @param {string} [error] - Error message if failed
901
+ * @returns {string} Formatted act complete message
902
+ */
903
+ formatActComplete(durationMs, success, error = null) {
904
+ const parts = [];
905
+ this.addTimestamp(parts);
906
+ parts.push(this.getResultPrefix());
907
+
908
+ if (success) {
909
+ parts.push(chalk.green("complete"));
910
+ } else {
911
+ parts.push(chalk.red("failed"));
912
+ if (error) {
913
+ parts.push(chalk.dim("·"));
914
+ parts.push(chalk.red(error));
915
+ }
916
+ }
917
+
918
+ parts.push(this.formatDurationColored(durationMs, "default"));
919
+
920
+ return parts.join(" ");
921
+ }
881
922
  }
882
923
 
883
924
  // Export singleton instance
package/sdk.d.ts CHANGED
@@ -242,6 +242,8 @@ export interface TestDriverOptions {
242
242
  sandboxInstance?: string;
243
243
  /** Cache key for element finding operations. If provided, enables caching tied to this key */
244
244
  cacheKey?: string;
245
+ /** Reconnect to the last used sandbox (throws error if no last sandbox exists) */
246
+ reconnect?: boolean;
245
247
  /** Redraw configuration for screen change detection */
246
248
  redraw?: boolean | {
247
249
  /** Enable redraw detection (default: true) */
@@ -264,6 +266,8 @@ export interface ConnectOptions {
264
266
  sandboxId?: string;
265
267
  /** Force creation of a new sandbox */
266
268
  newSandbox?: boolean;
269
+ /** Reconnect to the last used sandbox (throws error if no last sandbox exists) */
270
+ reconnect?: boolean;
267
271
  /** Direct IP address to connect to a running sandbox instance */
268
272
  ip?: string;
269
273
  /** Custom AMI ID for sandbox instance (e.g., 'ami-1234') */
@@ -276,6 +280,8 @@ export interface ConnectOptions {
276
280
  headless?: boolean;
277
281
  /** Reuse recent connection if available (default: true) */
278
282
  reuseConnection?: boolean;
283
+ /** Keep sandbox alive for specified milliseconds after disconnect (default: 60000). Set to 0 to terminate immediately on disconnect. */
284
+ keepAlive?: number;
279
285
  }
280
286
 
281
287
  export interface SandboxInstance {
@@ -695,6 +701,18 @@ export default class TestDriverSDK {
695
701
  */
696
702
  disconnect(): Promise<void>;
697
703
 
704
+ /**
705
+ * Get the last sandbox info from the stored file
706
+ * @returns Last sandbox info or null if not found
707
+ */
708
+ getLastSandboxId(): {
709
+ sandboxId: string | null;
710
+ os: 'windows' | 'linux';
711
+ ami: string | null;
712
+ instanceType: string | null;
713
+ timestamp: string | null;
714
+ } | null;
715
+
698
716
  // Element Finding API
699
717
 
700
718
  /**
@@ -702,7 +720,7 @@ export default class TestDriverSDK {
702
720
  * Automatically locates the element and returns it
703
721
  *
704
722
  * @param description - Description of the element to find
705
- * @param cacheThreshold - Cache threshold for this specific find (overrides global setting)
723
+ * @param options - Cache threshold (number) or options object
706
724
  * @returns Chainable promise that resolves to Element instance
707
725
  *
708
726
  * @example
@@ -719,17 +737,12 @@ export default class TestDriverSDK {
719
737
  * const element = await client.find('login button', 0.01);
720
738
  *
721
739
  * @example
722
- * // Poll until element is found
723
- * let element;
724
- * while (!element?.found()) {
725
- * element = await client.find('login button');
726
- * if (!element.found()) {
727
- * await new Promise(resolve => setTimeout(resolve, 1000));
728
- * }
729
- * }
740
+ * // Poll for element with timeout (retries every 5 seconds)
741
+ * const element = await client.find('loading complete indicator', { timeout: 30000 });
730
742
  * await element.click();
731
743
  */
732
744
  find(description: string, cacheThreshold?: number): ChainableElementPromise;
745
+ find(description: string, options?: { cacheThreshold?: number; cacheKey?: string; timeout?: number }): ChainableElementPromise;
733
746
 
734
747
  /**
735
748
  * Find all elements matching a description