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
@@ -295,6 +295,6 @@ describe('Scrolling', () => {
295
295
 
296
296
  ## Related Methods
297
297
 
298
- - [`find()`](/v7/api/find) - Locate elements after scrolling
299
- - [`pressKeys()`](/v7/api/pressKeys) - Use Page Down/Up keys
300
- - [`wait()`](/v7/api/wait) - Wait after scrolling
298
+ - [`find()`](/v7/find) - Locate elements after scrolling
299
+ - [`pressKeys()`](/v7/press-keys) - Use Page Down/Up keys
300
+ - [`wait()`](/v7/wait) - Wait after scrolling
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: "Using Secrets"
3
+ description: "Securely manage passwords and sensitive data in your tests"
4
+ icon: "key"
5
+ ---
6
+
7
+ Protect sensitive information like passwords, API keys, and tokens in your TestDriver tests.
8
+
9
+ ## Typing Secrets Securely
10
+
11
+ When typing sensitive information like passwords, use the `secret: true` option to prevent the value from being logged or stored:
12
+
13
+ ```javascript
14
+ import { test } from 'vitest';
15
+ import { chrome } from 'testdriverai/presets';
16
+
17
+ test('login with secure password', async (context) => {
18
+ const { testdriver } = await chrome(context, {
19
+ url: 'https://myapp.com/login'
20
+ });
21
+
22
+ await testdriver.find('email input').click();
23
+ await testdriver.type(process.env.TD_USERNAME);
24
+
25
+ await testdriver.find('password input').click();
26
+ // Password is masked in logs and recordings
27
+ await testdriver.type(process.env.TD_PASSWORD, { secret: true });
28
+
29
+ await testdriver.find('login button').click();
30
+ await testdriver.assert('dashboard is visible');
31
+ });
32
+ ```
33
+
34
+ <Note>
35
+ When `secret: true` is set, the typed text appears as `****` in all logs, recordings, and dashcam output.
36
+ </Note>
37
+
38
+ ## Storing Secrets in GitHub
39
+
40
+ Store sensitive credentials as GitHub repository secrets so they're never exposed in your code:
41
+
42
+ <Steps>
43
+ <Step title="Navigate to Repository Settings">
44
+ Go to your GitHub repository → **Settings** → **Secrets and variables** → **Actions**
45
+ </Step>
46
+ <Step title="Add Repository Secrets">
47
+ Click **New repository secret** and add your secrets:
48
+ - `TD_API_KEY` - Your TestDriver API key
49
+ - `TD_USERNAME` - Test account username
50
+ - `TD_PASSWORD` - Test account password
51
+ </Step>
52
+ <Step title="Use in GitHub Actions">
53
+ Reference secrets in your workflow file:
54
+ ```yaml .github/workflows/test.yml
55
+ - name: Run TestDriver tests
56
+ env:
57
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
58
+ TD_USERNAME: ${{ secrets.TD_USERNAME }}
59
+ TD_PASSWORD: ${{ secrets.TD_PASSWORD }}
60
+ run: npx vitest run
61
+ ```
62
+ </Step>
63
+ </Steps>
64
+
65
+ ## Local Development
66
+
67
+ For local development, store secrets in a `.env` file:
68
+
69
+ ```bash .env
70
+ TD_API_KEY=your_api_key_here
71
+ TD_USERNAME=testuser@example.com
72
+ TD_PASSWORD=your_secure_password
73
+ ```
74
+
75
+ <Warning>
76
+ Never commit `.env` files to version control. Add `.env` to your `.gitignore` file.
77
+ </Warning>
78
+
79
+ ## Complete Example
80
+
81
+ Here's a full login test with proper secrets handling:
82
+
83
+ ```javascript tests/login.test.js
84
+ import { test, expect } from 'vitest';
85
+ import { chrome } from 'testdriverai/presets';
86
+
87
+ test('secure login flow', async (context) => {
88
+ const { testdriver } = await chrome(context, {
89
+ url: process.env.TD_WEBSITE || 'https://staging.myapp.com'
90
+ });
91
+
92
+ // Enter username (not sensitive)
93
+ await testdriver.find('email input').click();
94
+ await testdriver.type(process.env.TD_USERNAME);
95
+
96
+ // Enter password securely
97
+ await testdriver.find('password input').click();
98
+ await testdriver.type(process.env.TD_PASSWORD, { secret: true });
99
+
100
+ // Submit login
101
+ await testdriver.find('login button').click();
102
+
103
+ // Verify successful login
104
+ const loggedIn = await testdriver.assert('user is logged in');
105
+ expect(loggedIn).toBeTruthy();
106
+ });
107
+ ```
108
+
109
+ <Card title="Secrets Best Practices" icon="shield-check">
110
+ - **Always use `secret: true`** when typing passwords, tokens, or sensitive data
111
+ - **Use environment variables** to keep secrets out of code
112
+ - **Store secrets in your CI provider** (GitHub Actions, GitLab CI, etc.)
113
+ - **Never commit secrets** to version control
114
+ - **Rotate secrets regularly** to maintain security
115
+ </Card>
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: "Self-Hosted"
3
+ sidebarTitle: "Self-Hosted"
4
+ description: "Unlimited test execution, complete privacy, and the ability to customize everything — all for a predictable flat license fee."
5
+ icon: "server"
6
+ ---
7
+
8
+ Self-hosted pricing is based on **parallel test capacity**: the number of tests you can run simultaneously on **your infrastructure**.
9
+
10
+ With self-hosting, you get:.
11
+
12
+ - **Flat license fee** per parallel test slot
13
+ - **Unlimited test execution** — run as many tests as you want
14
+ - **No device-second metering** — predictable monthly costs
15
+ - **Use your own AI keys** — control data usage with your own OpenAI, Anthropic, or other AI provider keys
16
+ - **Custom hardware & software** — choose instance types, resolution, install specific software, and configure networking as needed
17
+ - **Debug & Customize** — RDP into test machines, install custom software, modify the AMI, and debug issues directly. No black boxes.
18
+
19
+ ## Get Started
20
+
21
+ Ready to self-host? Follow our comprehensive AWS setup guide:
22
+
23
+ <Card
24
+ title="AWS Setup Guide"
25
+ icon="aws"
26
+ href="/v7/aws-setup"
27
+ >
28
+ Step-by-step instructions for deploying TestDriver on your AWS infrastructure using CloudFormation.
29
+ </Card>
30
+
31
+
32
+ ## Who Should Self-Host?
33
+
34
+ Self-hosting is ideal for teams that:
35
+
36
+ - **Run high test volumes** — Flat pricing becomes more economical at scale
37
+ - **Want infrastructure control** — Custom hardware, specific software dependencies, or network configurations
38
+ - **Prefer predictable costs** — Budget with confidence using flat monthly fees
39
+
40
+
41
+ ## How It Works
42
+
43
+ With self-hosting, you run test sandboxes on your own AWS infrastructure. TestDriver still provides:
44
+
45
+ - **Dashboard** — View test results, analytics, and reports at [console.testdriver.ai](https://console.testdriver.ai)
46
+ - **API** — Orchestration and AI-powered test execution
47
+ - **License Management** — Your parallel test capacity
48
+
49
+ You provide:
50
+
51
+ - **AWS Infrastructure** — EC2 instances running in your account
52
+ - **AI API Keys** — Use your own OpenAI, Anthropic, or other AI provider keys
53
+ - **Custom Configuration** — Hardware specs, networking, installed software
54
+
55
+ ## Comparison vs Cloud
56
+
57
+ | Feature | Cloud | Self-Hosted |
58
+ |---------|-------|-------------|
59
+ | **Setup Time** | Minutes | Hours |
60
+ | **Pricing Model** | Device-seconds | Flat license fee |
61
+ | **Infrastructure Management** | TestDriver | You |
62
+ | **Device Location** | TestDriver cloud | Your AWS account |
63
+ | **AI API Keys** | TestDriver's | Your own |
64
+ | **Custom Software** | Limited | Full control |
65
+ | **Hardware Selection** | Standard | Your choice |
66
+ | **Debugging Access** | Replays only | Full RDP access |
@@ -353,6 +353,6 @@ describe('Form Filling with Type', () => {
353
353
 
354
354
  ## Related Methods
355
355
 
356
- - [`pressKeys()`](/v7/api/pressKeys) - Press keyboard keys and shortcuts
357
- - [`find()`](/v7/api/find) - Locate input fields
358
- - [`click()`](/v7/api/click) - Focus input fields
356
+ - [`pressKeys()`](/v7/press-keys) - Press keyboard keys and shortcuts
357
+ - [`find()`](/v7/find) - Locate input fields
358
+ - [`click()`](/v7/click) - Focus input fields
@@ -0,0 +1,111 @@
1
+ ---
2
+ title: "Using Variables"
3
+ description: "Use dynamic data and secure secrets in your tests"
4
+ icon: "square-root-variable"
5
+ ---
6
+
7
+ Scale your testing with dynamic data and secure secrets management. Choose the right approach based on your testing needs.
8
+
9
+ ## Environment Variables
10
+
11
+ Environment variables are ideal for **configuration that changes between environments** (dev, staging, production) or for **secrets that shouldn't be committed to code**. Use this approach when you need to run the same tests against different servers or with different credentials.
12
+
13
+ ```javascript
14
+ import { test } from 'vitest';
15
+ import { chrome } from 'testdriverai/presets';
16
+
17
+ test('multi-environment testing', async (context) => {
18
+ const env = process.env.TEST_ENV || 'staging';
19
+ const urls = {
20
+ dev: 'https://dev.myapp.com',
21
+ staging: 'https://staging.myapp.com',
22
+ production: 'https://myapp.com'
23
+ };
24
+
25
+ const { testdriver } = await chrome(context, {
26
+ url: urls[env]
27
+ });
28
+
29
+ await testdriver.assert('app is running');
30
+ });
31
+ ```
32
+
33
+ ```bash
34
+ # Run against different environments
35
+ TEST_ENV=dev npx vitest run
36
+ TEST_ENV=staging npx vitest run
37
+ TEST_ENV=production npx vitest run
38
+ ```
39
+
40
+ ## Test Fixtures
41
+
42
+ Test fixtures work best when you have **structured, reusable test data** that needs to be shared across multiple tests. Use fixtures when testing different user roles, product catalogs, or any scenario where you want to parameterize tests with a known set of data.
43
+
44
+ ```javascript test/fixtures/users.js
45
+ export const testUsers = [
46
+ { email: 'admin@test.com', role: 'admin' },
47
+ { email: 'user@test.com', role: 'user' },
48
+ { email: 'guest@test.com', role: 'guest' }
49
+ ];
50
+
51
+ export const products = [
52
+ { name: 'Laptop', price: 999 },
53
+ { name: 'Mouse', price: 29 },
54
+ { name: 'Keyboard', price: 89 }
55
+ ];
56
+ ```
57
+
58
+ ```javascript test/permissions.test.js
59
+ import { test } from 'vitest';
60
+ import { chrome } from 'testdriverai/presets';
61
+ import { testUsers } from './fixtures/users.js';
62
+
63
+ test.each(testUsers)('$role can access dashboard', async ({ email, role }, context) => {
64
+ const { testdriver } = await chrome(context, { url });
65
+
66
+ await testdriver.find('email input').type(email);
67
+ await testdriver.find('password input').type('password123');
68
+ await testdriver.find('login button').click();
69
+
70
+ if (role === 'admin') {
71
+ await testdriver.assert('admin panel is visible');
72
+ } else {
73
+ await testdriver.assert('user dashboard is visible');
74
+ }
75
+ });
76
+ ```
77
+
78
+ ## Dynamic Data Generation
79
+
80
+ Dynamic data generation is perfect for **creating unique test data on each run**, avoiding conflicts with existing records, and **testing edge cases with realistic data**. Use libraries like Faker when you need fresh emails, names, or other data that won't collide with previous test runs.
81
+
82
+ ```javascript
83
+ import { test } from 'vitest';
84
+ import { chrome } from 'testdriverai/presets';
85
+ import { faker } from '@faker-js/faker';
86
+
87
+ test('user registration with dynamic data', async (context) => {
88
+ const { testdriver } = await chrome(context, { url });
89
+
90
+ // Generate unique test data for each run
91
+ const userData = {
92
+ firstName: faker.person.firstName(),
93
+ lastName: faker.person.lastName(),
94
+ email: faker.internet.email(),
95
+ password: faker.internet.password({ length: 12 })
96
+ };
97
+
98
+ await testdriver.find('first name input').type(userData.firstName);
99
+ await testdriver.find('last name input').type(userData.lastName);
100
+ await testdriver.find('email input').type(userData.email);
101
+ await testdriver.find('password input').type(userData.password);
102
+ await testdriver.find('register button').click();
103
+
104
+ await testdriver.assert('registration successful');
105
+ console.log('Registered user:', userData.email);
106
+ });
107
+ ```
108
+
109
+ ```bash
110
+ npm install --save-dev @faker-js/faker
111
+ ```
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: "Waiting for Elements"
3
+ description: "Handle async operations and prevent flaky tests"
4
+ icon: "clock"
5
+ ---
6
+
7
+ ## Waiting for Elements
8
+
9
+ Use the `timeout` option with `find()` to wait for elements that appear after async operations:
10
+
11
+ ```javascript
12
+ // Wait up to 30 seconds for element to appear (polls every 5 seconds)
13
+ const element = await testdriver.find('Loading complete indicator', { timeout: 30000 });
14
+ await element.click();
15
+
16
+ // Useful after actions that trigger loading states
17
+ await testdriver.find('submit button').click();
18
+ await testdriver.find('success message', { timeout: 15000 });
19
+
20
+ // Short timeout for quick checks
21
+ const toast = await testdriver.find('notification toast', { timeout: 5000 });
22
+ ```
23
+
24
+ ## Flake Prevention
25
+
26
+ TestDriver automatically waits for the screen and network to stabilize after each action using **redraw detection**. This prevents flaky tests caused by animations, loading states, or dynamic content updates.
27
+
28
+ <Note>
29
+ Redraw detection adds a small delay after each action but significantly reduces test flakiness.
30
+ </Note>
31
+
32
+ For example, when clicking a submit button that navigates to a new page:
33
+
34
+ ```javascript
35
+ // Click submit - TestDriver automatically waits for the new page to load
36
+ await testdriver.find('submit button').click();
37
+
38
+ // By the time this runs, the page has fully loaded and stabilized
39
+ await testdriver.assert('dashboard is displayed');
40
+ await testdriver.find('welcome message');
41
+ ```
42
+
43
+ Without redraw detection, you'd need manual waits or retries to handle the page transition. TestDriver handles this automatically by detecting when the screen stops changing and network requests complete.
44
+
45
+ You can disable redraw detection or customize its behavior:
46
+
47
+ ```javascript
48
+ // Disable redraw detection for faster tests (less reliable)
49
+ const testdriver = TestDriver(context, {
50
+ redraw: false
51
+ });
52
+ ```
53
+
54
+ Here is an example of customizing redraw detection:
55
+
56
+ ```javascript
57
+ // Fine-tune redraw detection
58
+ const testdriver = TestDriver(context, {
59
+ redraw: {
60
+ enabled: true,
61
+ diffThreshold: 0.1, // Pixel difference threshold (0-1)
62
+ screenRedraw: true, // Monitor screen changes
63
+ networkMonitor: true, // Wait for network idle
64
+ }
65
+ });
66
+ ```
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: "What is TestDriver?"
3
+ description: "Reliably test your most difficult user flows"
4
+ icon: "circle-info"
5
+ ---
6
+
7
+ ## The problem with modern testing tools
8
+
9
+ Modern testing tools like Playwright are designed to test a single web application, running in a single browser tab using selectors.
10
+
11
+ However, selectors are often either unreliable or unavailable in complex scenarios, leading to brittle and flaky tests:
12
+
13
+ | Challenge | Problem | Examples |
14
+ |-----------|---------|----------|
15
+ | **Fast moving teams** | Frequently change UI structure, breaking CSS/XPath selectors | Agile teams, startups, vibe-coders |
16
+ | **Dynamic content** | Cannot be targeted with selectors | AI chatbots, PDFs, images, videos |
17
+ | **Software you don't own** | May lack proper accessibility attributes | Other websites, extensions, third-party applications |
18
+ | **Multi-application workflows** | Cannot be tested with web-only tools | Desktop apps, browser extensions, IDEs |
19
+ | **Visual states** | Impossible to verify with code-based selectors | Charts, graphs, videos, images, spelling errors, UI layout |
20
+
21
+ ## The TestDriver Solution
22
+
23
+ TestDriver is a complete testing platform built specifically for handling these scenarios. It consists of a Javascript SDK, hosted infrastructure, and debugging tools that make it easy to write, run, and maintain tests for your most difficult user flows.
24
+
25
+ ### Javascript SDK
26
+
27
+ Here is an example of a TestDriver test that installs a production Chrome extension from the Chrome Web Store and verifies that it appears in the extensions menu:
28
+
29
+ ```javascript Installing Loom from the Chrome Web Store
30
+ import { describe, expect, it } from "vitest";
31
+ import { TestDriver } from "testdriverai/vitest/hooks";
32
+
33
+ describe("Chrome Extension Test", () => {
34
+ const testdriver = TestDriver(context);
35
+
36
+ // Launch Chrome with Loom loaded by its Chrome Web Store ID
37
+ await testdriver.provision.chromeExtension({
38
+ extensionId: 'liecbddmkiiihnedobmlmillhodjkdmb'
39
+ });
40
+
41
+ // Click on the extensions button (puzzle piece icon) in Chrome toolbar
42
+ const extensionsButton = await testdriver.find("The puzzle-shaped icon in the Chrome toolbar.");
43
+ await extensionsButton.click();
44
+
45
+ // Look for Loom in the extensions menu
46
+ const loomExtension = await testdriver.find("Loom extension in the extensions dropdown");
47
+ expect(loomExtension.found()).toBeTruthy();
48
+ });
49
+ ```
50
+
51
+
52
+ <Tip>[vitest](https://vitest.dev/) is the preferred test runner for TestDriver.</Tip>
53
+
54
+ ,
@@ -24,6 +24,7 @@ class InitCommand extends BaseCommand {
24
24
 
25
25
  console.log(chalk.green("\n✅ Project initialized successfully!\n"));
26
26
  this.printNextSteps();
27
+ process.exit(0);
27
28
  }
28
29
 
29
30
  /**
@@ -79,28 +80,41 @@ class InitCommand extends BaseCommand {
79
80
  */
80
81
  async promptHidden(question) {
81
82
  return new Promise((resolve) => {
82
- const rl = readline.createInterface({
83
- input: process.stdin,
84
- output: process.stdout,
85
- });
86
-
87
- // Mute output to hide the input
83
+ process.stdout.write(question);
84
+
88
85
  const stdin = process.stdin;
89
- const muted = {
90
- write: () => {},
86
+ const wasRaw = stdin.isRaw;
87
+ stdin.setRawMode(true);
88
+ stdin.resume();
89
+ stdin.setEncoding("utf8");
90
+
91
+ let input = "";
92
+
93
+ const onData = (char) => {
94
+ // Handle Ctrl+C
95
+ if (char === "\u0003") {
96
+ stdin.setRawMode(wasRaw);
97
+ process.exit();
98
+ }
99
+ // Handle Enter
100
+ if (char === "\r" || char === "\n") {
101
+ stdin.setRawMode(wasRaw);
102
+ stdin.removeListener("data", onData);
103
+ stdin.pause();
104
+ console.log(""); // New line after hidden input
105
+ resolve(input);
106
+ return;
107
+ }
108
+ // Handle Backspace
109
+ if (char === "\u007F" || char === "\b") {
110
+ input = input.slice(0, -1);
111
+ return;
112
+ }
113
+ // Add character to input (but don't echo it)
114
+ input += char;
91
115
  };
92
116
 
93
- rl.question(question, (answer) => {
94
- rl.close();
95
- stdin.removeListener("data", muted.write);
96
- console.log(""); // New line after hidden input
97
- resolve(answer);
98
- });
99
-
100
- // Mute stdin to hide input
101
- stdin.on("data", (char) => {
102
- // Don't write to output (hides the input)
103
- });
117
+ stdin.on("data", onData);
104
118
  });
105
119
  }
106
120
 
@@ -23,6 +23,7 @@ async function openBrowser(url) {
23
23
  await open(url, {
24
24
  // Wait for the app to open
25
25
  wait: false,
26
+ background: true
26
27
  });
27
28
  } catch (error) {
28
29
  console.error("Failed to open browser automatically:", error);
@@ -131,9 +132,32 @@ class BaseCommand extends Command {
131
132
  }
132
133
 
133
134
  this.agent.emitter.on("exit", (exitCode) => {
135
+ // Ensure sandbox is closed before exiting
136
+ if (this.agent?.sandbox) {
137
+ try {
138
+ this.agent.sandbox.close();
139
+ } catch (err) {
140
+ // Ignore close errors
141
+ }
142
+ }
134
143
  process.exit(exitCode);
135
144
  });
136
145
 
146
+ // Handle process signals to ensure clean disconnection
147
+ const cleanupAndExit = () => {
148
+ if (this.agent?.sandbox) {
149
+ try {
150
+ this.agent.sandbox.close();
151
+ } catch (err) {
152
+ // Ignore close errors
153
+ }
154
+ }
155
+ process.exit(1);
156
+ };
157
+
158
+ process.on('SIGINT', cleanupAndExit);
159
+ process.on('SIGTERM', cleanupAndExit);
160
+
137
161
  // Handle unhandled promise rejections to prevent them from interfering with the exit flow
138
162
  // This is particularly important when JavaScript execution in VM contexts leaves dangling promises
139
163
  process.on("unhandledRejection", (reason) => {
package/interfaces/cli.js CHANGED
@@ -1,13 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { run } = require("@oclif/core");
4
+ const sentry = require("../lib/sentry");
4
5
 
5
6
  // Run oclif (with default command handling built-in)
6
7
  run()
7
8
  .then(() => {
8
9
  // Success
9
10
  })
10
- .catch((error) => {
11
+ .catch(async (error) => {
12
+ // Capture error in Sentry
13
+ sentry.captureException(error, {
14
+ tags: { component: "cli-init" },
15
+ });
16
+ await sentry.flush();
17
+
11
18
  console.error("Failed to start TestDriver.ai agent:", error);
12
19
  process.exit(1);
13
20
  });
@@ -300,6 +300,9 @@ marked.use(
300
300
  );
301
301
 
302
302
  const createMarkdownLogger = (emitter) => {
303
+ // Indent prefix for streaming AI thoughts - makes it visually distinct and scoped
304
+ const streamIndent = "";
305
+
303
306
  const markedParsePartial = (markdown, start = 0, end = 0) => {
304
307
  let result = markdown.trimEnd().split("\n").slice(start, end);
305
308
  if (end <= 0) {
@@ -307,7 +310,8 @@ const createMarkdownLogger = (emitter) => {
307
310
  }
308
311
  result = result.join("\n");
309
312
 
310
- return marked.parse(result).replace(/^/gm, spaceChar).trimEnd();
313
+ // Use streamIndent for streaming output to make it visually scoped
314
+ return marked.parse(result).replace(/^/gm, streamIndent).trimEnd();
311
315
  };
312
316
 
313
317
  // Event-based markdown streaming with buffering
@@ -360,7 +364,8 @@ const createMarkdownLogger = (emitter) => {
360
364
  diff = censorSensitiveDataDeep(diff);
361
365
  process.stdout.write(diff);
362
366
  }
363
- process.stdout.write("\n\n");
367
+ // Use console.log for the final newlines so it gets captured by vitest
368
+ console.log("");
364
369
 
365
370
  // Clean up the stream
366
371
  activeStreams.delete(streamId);
@@ -384,7 +389,7 @@ const createMarkdownLogger = (emitter) => {
384
389
  });
385
390
  };
386
391
 
387
- const spaceChar = " ";
392
+ const spaceChar = " ";
388
393
 
389
394
  module.exports = {
390
395
  logger,