testdriverai 6.0.27-canary.ea72c58.0 → 6.0.27
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/agent/index.js +9 -1
- package/agent/lib/commands.js +6 -1
- package/docs/cli/overview.mdx +1 -0
- package/docs/docs.json +11 -16
- package/docs/getting-started/vscode.mdx +62 -56
- package/docs/images/content/vscode/ide-full.png +0 -0
- package/docs/images/content/vscode/running.png +0 -0
- package/docs/overview/comparison.mdx +3 -1
- package/docs/overview/quickstart.mdx +84 -31
- package/interfaces/cli/lib/base.js +8 -0
- package/package.json +1 -1
- package/testdriver/acceptance/prompt.yaml +4 -1
- package/testdriver/edge-cases/js-exception.yaml +8 -0
- package/testdriver/edge-cases/js-promise.yaml +19 -0
- package/testdriver/edge-cases/lifecycle/postrun.yaml +10 -0
- package/testdriver/edge-cases/success-test.yaml +9 -0
- package/testdriver/lifecycle/provision.yaml +1 -1
package/agent/index.js
CHANGED
|
@@ -222,7 +222,15 @@ class TestDriverAgent extends EventEmitter2 {
|
|
|
222
222
|
if (skipPostrun) {
|
|
223
223
|
this.exit(true);
|
|
224
224
|
} else {
|
|
225
|
-
|
|
225
|
+
try {
|
|
226
|
+
await this.summarize(error.message);
|
|
227
|
+
} catch (summarizeError) {
|
|
228
|
+
// If summarization fails, log it but don't let it prevent postrun from running
|
|
229
|
+
this.emitter.emit(
|
|
230
|
+
events.log.warn,
|
|
231
|
+
theme.yellow(`Failed to summarize: ${summarizeError.message}`),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
226
234
|
// Always run postrun lifecycle script, even for fatal errors
|
|
227
235
|
return await this.exit(true, false, true);
|
|
228
236
|
}
|
package/agent/lib/commands.js
CHANGED
|
@@ -766,7 +766,12 @@ const createCommands = (
|
|
|
766
766
|
try {
|
|
767
767
|
await script.runInNewContext(context);
|
|
768
768
|
} catch (e) {
|
|
769
|
-
console.error
|
|
769
|
+
// Log the error to the emitter instead of console.error to maintain consistency
|
|
770
|
+
emitter.emit(
|
|
771
|
+
events.log.debug,
|
|
772
|
+
`JavaScript execution error: ${e.message}`,
|
|
773
|
+
);
|
|
774
|
+
// Wait a tick to allow any promise rejections to be handled
|
|
770
775
|
throw new CommandError(`Error running script: ${e.message}`);
|
|
771
776
|
}
|
|
772
777
|
|
package/docs/cli/overview.mdx
CHANGED
|
@@ -30,6 +30,7 @@ npx testdriverai@latest <command> [options]
|
|
|
30
30
|
| `--headless` | Run test without opening a browser window (useful for CI/CD environments) |
|
|
31
31
|
| `--new` | Create a new sandbox environment for the test run. |
|
|
32
32
|
| `--summary=<value>` | Output file where AI summary should be saved. |
|
|
33
|
+
| `--junit=<value>` | Output file where junit report should be saved. |
|
|
33
34
|
|
|
34
35
|
## Example usage
|
|
35
36
|
|
package/docs/docs.json
CHANGED
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"group": "CLI",
|
|
39
39
|
"icon": "terminal",
|
|
40
40
|
"pages": [
|
|
41
|
-
"/getting-started/cli",
|
|
42
41
|
"/cli/overview",
|
|
43
42
|
{
|
|
44
43
|
"group": "Commands",
|
|
@@ -50,7 +49,8 @@
|
|
|
50
49
|
]
|
|
51
50
|
}
|
|
52
51
|
]
|
|
53
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"/getting-started/vscode"
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
{
|
|
@@ -172,16 +172,7 @@
|
|
|
172
172
|
"/commands/wait-for-text"
|
|
173
173
|
]
|
|
174
174
|
}
|
|
175
|
-
]
|
|
176
|
-
"global": {
|
|
177
|
-
"anchors": [
|
|
178
|
-
{
|
|
179
|
-
"anchor": "Book a Demo",
|
|
180
|
-
"href": "https://testdriver.ai/demo",
|
|
181
|
-
"icon": "calendar"
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
}
|
|
175
|
+
]
|
|
185
176
|
},
|
|
186
177
|
"modeToggle": {
|
|
187
178
|
"enabled": false,
|
|
@@ -198,13 +189,17 @@
|
|
|
198
189
|
"label": "Discord",
|
|
199
190
|
"icon": "discord",
|
|
200
191
|
"href": "https://discord.com/invite/cWDFW8DzPm"
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"label": "Book a Demo",
|
|
195
|
+
"href": "https://form.typeform.com/to/UECf9rDx?typeform-source=docs.testdriver.ai",
|
|
196
|
+
"icon": "calendar"
|
|
197
|
+
}, {
|
|
198
|
+
"icon": "gauge-high",
|
|
205
199
|
"label": "Dashboard",
|
|
206
200
|
"href": "https://app.testdriver.ai"
|
|
207
201
|
}
|
|
202
|
+
]
|
|
208
203
|
},
|
|
209
204
|
"footer": {
|
|
210
205
|
"socials": {
|
|
@@ -1,75 +1,81 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Install the TestDriver VS Code Extension"
|
|
3
|
-
sidebarTitle: "VS Code
|
|
3
|
+
sidebarTitle: "VS Code (Beta)"
|
|
4
4
|
description: "Comprehensive guide to installing and setting up TestDriver for VS Code"
|
|
5
5
|
icon: "file-code"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
<iframe
|
|
9
|
+
className="w-full aspect-video rounded-xl"
|
|
10
|
+
src="https://www.youtube.com/embed/dell_2tI6nc"
|
|
11
|
+
title="YouTube video player"
|
|
12
|
+
frameBorder="0"
|
|
13
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
14
|
+
allowFullScreen
|
|
15
|
+
></iframe>
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
<Step title="Initialize Your Project" stepNumber={1}>
|
|
19
|
-
Set up your project with:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npx testdriverai@latest init
|
|
23
|
-
```
|
|
17
|
+
The TestDriver VS Code extension is a powerful tool that integrates TestDriver's AI-driven test generation capabilities directly into your development environment:
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
- Get started with example scripts for different platforms
|
|
20
|
+
- Get syntax highlighting and autocompletion for [TestDriver YAML](/getting-started/editing)
|
|
21
|
+
- Chat with the TestDriver agent to generate tests based on your requirements
|
|
22
|
+
- Save and manage your tests directly within your project
|
|
23
|
+
- Run and debug tests directly from the IDE
|
|
24
|
+
- View test results and logs within the IDE
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
<Step title="Run TestDriver in Interactive Mode" stepNumber={2}>
|
|
29
|
-
Start TestDriver in interactive mode to create and refine tests dynamically:
|
|
26
|
+
<Tip>The TestDriver VS Code Extension is currently in beta. If you encounter any issues or have feedback, please let us know [in Discord](https://discord.com/invite/cWDFW8DzPm)</Tip>
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
<Steps>
|
|
29
|
+
<Step title="Install the VS Code Extension">
|
|
30
|
+
|
|
31
|
+
Click the button below to install the TestDriver extension for your preferred IDE. Then, follow the setup guide and chat with TestDriver to create your first test.
|
|
32
|
+
|
|
33
|
+
<Card
|
|
34
|
+
horizontal
|
|
35
|
+
title="VS Code"
|
|
36
|
+
arrow
|
|
37
|
+
href="vscode:extension/testdriver.testdriver"
|
|
38
|
+
icon="/images/content/extension/vscode.svg"
|
|
39
|
+
></Card>
|
|
40
|
+
|
|
41
|
+
<Card
|
|
42
|
+
horizontal
|
|
43
|
+
title="Cursor"
|
|
44
|
+
arrow
|
|
45
|
+
href="cursor:extension/testdriver.testdriver"
|
|
46
|
+
icon="/images/content/extension/cursor.svg"
|
|
47
|
+
|
|
48
|
+
> </Card>
|
|
49
|
+
|
|
50
|
+
<Card
|
|
51
|
+
horizontal
|
|
52
|
+
title="Windsurf"
|
|
53
|
+
arrow
|
|
54
|
+
href="windsurf:extension/testdriver.testdriver"
|
|
55
|
+
icon="/images/content/extension/windsurf.svg"
|
|
56
|
+
></Card>
|
|
36
57
|
|
|
37
58
|
</Step>
|
|
38
|
-
<Step title="
|
|
39
|
-
|
|
59
|
+
<Step title="Set Your TestDriver API Key">
|
|
60
|
+
|
|
61
|
+
After installing the extension, you'll need to set your TestDriver API key in the extension settings.
|
|
40
62
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
TestDriver will generate steps like:
|
|
46
|
-
|
|
47
|
-
```yaml
|
|
48
|
-
- command: focus-application
|
|
49
|
-
name: Google Chrome
|
|
50
|
-
- command: hover-text
|
|
51
|
-
text: Search Google or type a URL
|
|
52
|
-
description: main search bar
|
|
53
|
-
action: click
|
|
54
|
-
- command: type
|
|
55
|
-
text: testdriverai
|
|
56
|
-
- command: press-keys
|
|
57
|
-
keys:
|
|
58
|
-
- enter
|
|
59
|
-
```
|
|
63
|
+
1. Open the command palette (Cmd+Shift+P or Ctrl+Shift+P).
|
|
64
|
+
2. Search for "Preferences: Open Settings (UI)" and select it.
|
|
65
|
+
3. In the search bar, type "TestDriver" to filter the settings.
|
|
66
|
+
4. Find the "TestDriver: Set API Key" field and enter your API key from [the TestDriver dashboard](https://app.testdriver.ai/team).
|
|
60
67
|
|
|
68
|
+
<Tip>You can also set the `TD_API_KEY` environment variable in your system if you prefer not to enter it directly in the extension settings.</Tip>
|
|
69
|
+
|
|
61
70
|
</Step>
|
|
62
|
-
<Step title="
|
|
63
|
-
|
|
64
|
-
- Use `/run` to run the test.
|
|
71
|
+
<Step title="Choose a Platform">
|
|
72
|
+
Click on the TestDriver icon in the sidebar to open the extension panel and choose a platform to get started (Web, Desktop, or Mobile).
|
|
65
73
|
</Step>
|
|
66
|
-
<Step title="
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
74
|
+
<Step title="Create Your First Test">
|
|
75
|
+
Now chat with the TestDriver agent to create your first test! Describe what you want to test, and the agent will generate the test steps for you.
|
|
76
|
+
</Step>
|
|
77
|
+
<Step title="Run your test">
|
|
78
|
+
Run your test by clicking the "Run" button in the extension panel. You can view the test results and logs directly within VS Code's Test Explorer. [Learn more about running tests in VS Code](https://code.visualstudio.com/docs/debugtest/testing).
|
|
73
79
|
</Step>
|
|
74
80
|
</Steps>
|
|
75
81
|
|
|
Binary file
|
|
Binary file
|
|
@@ -13,6 +13,8 @@ TestDriver operates a full desktop environment, so it can run any application.
|
|
|
13
13
|
| Application | TestDriver | Playwright | Selenium |
|
|
14
14
|
|:-----------------:|:---------:|:-----------:|:--------:|
|
|
15
15
|
| Web Apps | ✅ | ✅ | ✅ |
|
|
16
|
+
| Mobile Apps | ✅ | ✅ | ✅ |
|
|
17
|
+
| VS Code | ✅ | ✅ | ✅ |
|
|
16
18
|
| Desktop Apps | ✅ | | |
|
|
17
19
|
| Chrome Extensions | ✅ | | |
|
|
18
20
|
</div>
|
|
@@ -96,4 +98,4 @@ TestDriver currently supports Mac and Windows!
|
|
|
96
98
|
| Windows | ✅ | ✅ | ✅ |
|
|
97
99
|
| Mac | ✅ | ✅ | ✅ |
|
|
98
100
|
| Linux | | ✅ | ✅ |
|
|
99
|
-
</div>
|
|
101
|
+
</div>
|
|
@@ -6,53 +6,106 @@ icon: "gauge-high"
|
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
<Tip>
|
|
10
|
-
You will need a [TestDriver Pro](https://app.testdriver.ai/team) account
|
|
11
|
-
($20/m) to complete setup.
|
|
12
|
-
</Tip>
|
|
13
9
|
|
|
14
10
|
<Steps>
|
|
15
|
-
<Step title="
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
<Step title="Create a TestDriver Account">
|
|
12
|
+
|
|
13
|
+
You will need a [TestDriver Pro](https://app.testdriver.ai/team) account ($20/month) to get an API key.
|
|
14
|
+
|
|
19
15
|
<Card
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
title="Sign Up for TestDriver"
|
|
17
|
+
icon="user-plus"
|
|
18
|
+
href="https://app.testdriver.ai/team"
|
|
22
19
|
arrow
|
|
23
|
-
|
|
24
|
-
icon="/images/content/extension/vscode.svg"
|
|
20
|
+
horizontal
|
|
25
21
|
></Card>
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
</Step>
|
|
24
|
+
<Step title="Set up your environment">
|
|
25
|
+
|
|
26
|
+
Copy your API key from [the TestDriver dashboard](https://app.testdriver.ai/team), and set it as an environment variable.
|
|
27
|
+
|
|
28
|
+
<Tabs>
|
|
29
|
+
<Tab title="macOS / Linux">
|
|
30
|
+
```bash Export an environment variable on macOS or Linux systems
|
|
31
|
+
export TD_API_KEY="your_api_key_here"
|
|
32
|
+
```
|
|
33
|
+
</Tab>
|
|
34
|
+
<Tab title="Windows">
|
|
35
|
+
```powershell Export an environment variable in PowerShell
|
|
36
|
+
setx TD_API_KEY "your_api_key_here"
|
|
37
|
+
```
|
|
38
|
+
</Tab>
|
|
39
|
+
</Tabs>
|
|
40
|
+
|
|
41
|
+
<Tip>Using VS Code, Cursor, or Windsurf? [Try our VS Code Extension (beta)](/getting-started/vscode).</Tip>
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
</Step>
|
|
44
|
+
<Step title="Check out an example test">
|
|
45
|
+
|
|
46
|
+
Download the TestDriver GitHub repository and run the example test.
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
href="windsurf:extension/testdriver.testdriver"
|
|
41
|
-
icon="/images/content/extension/windsurf.svg"
|
|
42
|
-
></Card>
|
|
48
|
+
```bash
|
|
49
|
+
git clone --depth 1 https://github.com/testdriverai/cli testdriverai
|
|
50
|
+
cd testdriverai/testdriver/acceptance
|
|
51
|
+
```
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
TestDriver tests are written in YAML, a human-readable data format. The `prompt.yaml` file contains an example series of steps for the agent to execute.
|
|
54
|
+
|
|
55
|
+
```yaml testdriver/acceptance/prompt.yaml
|
|
56
|
+
steps:
|
|
57
|
+
- prompt: log in
|
|
58
|
+
- prompt: add an item to the cart
|
|
59
|
+
- prompt: click on the cart icon
|
|
60
|
+
- prompt: complete checkout
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Each step has a `prompt` that describes what the agent should do. The agent will use the prompt to generate [commands](/commands/assert) that make the tests faster and more reliable the next time you run the test.
|
|
45
64
|
|
|
46
65
|
</Step>
|
|
47
|
-
<Step title="
|
|
66
|
+
<Step title="Generate regression test from prompts">
|
|
48
67
|
|
|
49
|
-
|
|
68
|
+
Run the following command to run the test file. TestDriver will spawn a virtual machine, launch the sandbox test page, and execute the steps defined in the `prompt.yaml` file.
|
|
50
69
|
|
|
51
70
|
```bash
|
|
52
|
-
|
|
71
|
+
npx testdriverai@latest run prompt.yaml --write --heal
|
|
53
72
|
```
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
The `--write` flag tells TestDriver to save any generated commands to the test file, and the `--heal` flag allows TestDriver to recover from unexpected issues during the test run.
|
|
75
|
+
|
|
76
|
+
<Tip>You can use an interactive CLI to generate test steps with the [explore command](/interactive/explore)</Tip>
|
|
77
|
+
|
|
78
|
+
</Step>
|
|
79
|
+
<Step title="Run the generated regression test">
|
|
80
|
+
|
|
81
|
+
After TestDriver has run the exploratory test, you'll see that the `prompt.yaml` file has been updated with commands generated by the agent to make the test faster and more reliable.
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
version: 6.0.0
|
|
85
|
+
steps:
|
|
86
|
+
- prompt: focus chrome
|
|
87
|
+
commands:
|
|
88
|
+
- command: focus-application
|
|
89
|
+
name: Google Chrome
|
|
90
|
+
- prompt: enter a username
|
|
91
|
+
commands:
|
|
92
|
+
- command: hover-text
|
|
93
|
+
text: Username
|
|
94
|
+
description: username input field
|
|
95
|
+
action: click
|
|
96
|
+
- command: type
|
|
97
|
+
text: standard_user
|
|
98
|
+
- prompt: enter a password
|
|
99
|
+
commands:
|
|
100
|
+
- command: hover-text
|
|
101
|
+
text: Password
|
|
102
|
+
description: password input field
|
|
103
|
+
action: click
|
|
104
|
+
- command: type
|
|
105
|
+
text: secret_password
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The `--write` command tells the agent to save the generated commands to the test file, and the `--heal` command gives the agent permission to recover if something goes wrong.
|
|
56
109
|
|
|
57
110
|
</Step>
|
|
58
111
|
|
|
@@ -124,6 +124,14 @@ class BaseCommand extends Command {
|
|
|
124
124
|
process.exit(exitCode);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
// Handle unhandled promise rejections to prevent them from interfering with the exit flow
|
|
128
|
+
// This is particularly important when JavaScript execution in VM contexts leaves dangling promises
|
|
129
|
+
process.on("unhandledRejection", (reason) => {
|
|
130
|
+
// Log the rejection but don't let it crash the process
|
|
131
|
+
console.error("Unhandled Promise Rejection:", reason);
|
|
132
|
+
// The exit flow should continue normally
|
|
133
|
+
});
|
|
134
|
+
|
|
127
135
|
// Handle show window events
|
|
128
136
|
this.agent.emitter.on("show-window", async (url) => {
|
|
129
137
|
console.log(`Live test execution: `);
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
version: 6.0.0
|
|
2
2
|
session: 6869c3e61445b2acbbdc0018
|
|
3
3
|
steps:
|
|
4
|
-
- prompt:
|
|
4
|
+
- prompt: log in
|
|
5
|
+
- prompt: add an item to the cart
|
|
6
|
+
- prompt: click on the cart icon
|
|
7
|
+
- prompt: complete checkout
|
|
5
8
|
- prompt: assert
|
|
6
9
|
commands:
|
|
7
10
|
- command: assert
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 5.1.1
|
|
2
|
+
session: 67f00511acbd9ccac373edf7
|
|
3
|
+
steps:
|
|
4
|
+
- prompt: execute powershell multiline
|
|
5
|
+
commands:
|
|
6
|
+
- command: exec
|
|
7
|
+
lang: js
|
|
8
|
+
code: |
|
|
9
|
+
const failingPromise = new Promise((resolve, reject) => {
|
|
10
|
+
try {
|
|
11
|
+
// Simulate some operation that fails
|
|
12
|
+
throw new Error("Something went wrong!");
|
|
13
|
+
} catch (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Usage
|
|
19
|
+
await failingPromise()
|
|
@@ -6,7 +6,7 @@ steps:
|
|
|
6
6
|
- command: exec
|
|
7
7
|
lang: pwsh
|
|
8
8
|
code: |
|
|
9
|
-
Start-Process "C:\Program Files\Google\Chrome\Application\chrome.exe" -ArgumentList "--start-maximized --disable-infobars --disable-fre --no-default-browser-check --no-first-run --guest --load-extension=$(pwd)/node_modules/dashcam-chrome/build", "
|
|
9
|
+
Start-Process "C:\Program Files\Google\Chrome\Application\chrome.exe" -ArgumentList "--start-maximized --disable-infobars --disable-fre --no-default-browser-check --no-first-run --guest --load-extension=$(pwd)/node_modules/dashcam-chrome/build", "https://testdriver-sandbox.vercel.app/"
|
|
10
10
|
- command: wait-for-text
|
|
11
11
|
text: ${TD_WEBSITE}
|
|
12
12
|
timeout: 60000
|