@testdriverai/mcp 7.9.149-test → 7.9.151-test

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 (42) hide show
  1. package/agent/interface.js +6 -0
  2. package/ai/skills/testdriver-caching/SKILL.md +13 -6
  3. package/ai/skills/testdriver-client/SKILL.md +5 -1
  4. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +14 -4
  5. package/ai/skills/testdriver-find/SKILL.md +2 -0
  6. package/ai/skills/testdriver-generating-tests/SKILL.md +159 -8
  7. package/ai/skills/testdriver-machine-setup/SKILL.md +75 -8
  8. package/ai/skills/testdriver-making-assertions/SKILL.md +78 -2
  9. package/ai/skills/testdriver-performing-actions/SKILL.md +97 -2
  10. package/ai/skills/testdriver-quickstart/SKILL.md +47 -28
  11. package/ai/skills/testdriver-wait/SKILL.md +1 -1
  12. package/ai/skills/testdriver:generating-tests/SKILL.md +0 -11
  13. package/docs/changelog.mdx +1 -1
  14. package/docs/docs.json +14 -39
  15. package/docs/v7/assert.mdx +0 -1
  16. package/docs/v7/caching.mdx +14 -10
  17. package/docs/v7/client.mdx +1 -1
  18. package/docs/v7/copilot/auto-healing.mdx +167 -18
  19. package/docs/v7/copilot/running-tests.mdx +915 -54
  20. package/docs/v7/debugging-with-screenshots.mdx +17 -7
  21. package/docs/v7/generating-tests.mdx +166 -10
  22. package/docs/v7/making-assertions.mdx +81 -4
  23. package/docs/v7/performing-actions.mdx +100 -4
  24. package/docs/v7/quickstart.mdx +299 -21
  25. package/docs/v7/wait.mdx +1 -1
  26. package/interfaces/cli/commands/init.js +2 -0
  27. package/lib/init-project.js +7 -0
  28. package/mcp-server/dist/server.mjs +2 -0
  29. package/mcp-server/src/server.ts +2 -0
  30. package/package.json +3 -3
  31. package/docs/v7/ai/agent.mdx +0 -72
  32. package/docs/v7/ai/mcp.mdx +0 -228
  33. package/docs/v7/ai/skills.mdx +0 -73
  34. package/docs/v7/ai.mdx +0 -205
  35. package/docs/v7/copilot/creating-tests.mdx +0 -156
  36. package/docs/v7/copilot/github.mdx +0 -143
  37. package/docs/v7/copilot/setup.mdx +0 -143
  38. package/docs/v7/device-config.mdx +0 -317
  39. package/docs/v7/locating-elements.mdx +0 -71
  40. package/docs/v7/machine-setup.mdx +0 -331
  41. package/docs/v7/running-tests.mdx +0 -185
  42. package/docs/v7/waiting-for-elements.mdx +0 -90
@@ -1,228 +0,0 @@
1
- ---
2
- title: "MCP Server"
3
- sidebarTitle: "MCP Server"
4
- description: "Install the TestDriver MCP server in any AI client — Claude Code, Cursor, VS Code, Windsurf, Codex, Zed, and more"
5
- icon: "plug"
6
- ---
7
-
8
- ## Overview
9
-
10
- The **TestDriver MCP server** exposes TestDriver's computer-use tools — `session_start`, `find`, `click`, `type`, `assert`, `check`, `screenshot`, and more — over the [Model Context Protocol](https://modelcontextprotocol.io). Any MCP-capable AI client can use it to drive a live sandbox and write real end-to-end tests.
11
-
12
- It runs as a local stdio process:
13
-
14
- ```bash
15
- npx -p testdriverai testdriverai-mcp
16
- ```
17
-
18
- and authenticates with your `TD_API_KEY` (from [console.testdriver.ai/team](https://console.testdriver.ai/team)).
19
-
20
- ## Quick install (recommended)
21
-
22
- `testdriverai init` wires up the MCP server, the [agent](/v7/ai/agent), and the [skills](/v7/ai/skills) for you, writing each client's config in the exact format and location it expects:
23
-
24
- ```bash
25
- # interactive — pick your client(s)
26
- npx testdriverai init
27
-
28
- # one client
29
- npx testdriverai init --client claude-code
30
-
31
- # several
32
- npx testdriverai init --client claude-code,cursor,vscode
33
-
34
- # everything
35
- npx testdriverai init --client all
36
- ```
37
-
38
- <Info>
39
- `init` detects clients already present in your project and pre-selects them in the picker. Re-running `init` is safe — it merges the TestDriver entry into existing config without overwriting your other servers.
40
- </Info>
41
-
42
- ## Client support matrix
43
-
44
- | Client | Auto-install | MCP config file | Config key |
45
- | --- | --- | --- | --- |
46
- | Claude Code | ✅ | `.mcp.json` | `mcpServers` |
47
- | Claude Desktop | ✅ | OS-specific (see below) | `mcpServers` |
48
- | Cursor | ✅ | `.cursor/mcp.json` | `mcpServers` |
49
- | VS Code (Copilot) | ✅ | `.vscode/mcp.json` | `servers` |
50
- | Windsurf | ✅ | `~/.codeium/windsurf/mcp_config.json` | `mcpServers` |
51
- | Codex | ✅ | `~/.codex/config.toml` | `[mcp_servers]` |
52
- | Zed | ✅ | `.zed/settings.json` | `context_servers` |
53
- | Lovable | ⚙️ partial | GitHub `AGENTS.md` + UI | — |
54
- | Replit | ⚙️ partial | `replit.md` + UI | — |
55
- | v0 (Vercel) | 📝 manual | web UI only | — |
56
-
57
- <Note>
58
- Each client uses a **different top-level key** for MCP servers. The most common mistake when configuring by hand is using `mcpServers` for VS Code (it wants `servers`), Codex (TOML `[mcp_servers]`), or Zed (`context_servers`).
59
- </Note>
60
-
61
- ## Manual installation
62
-
63
- If you'd rather configure by hand, use the snippets below. The stdio command is the same everywhere; only the wrapper key and file location change.
64
-
65
- <Tabs>
66
- <Tab title="Claude Code">
67
- Add to `.mcp.json` at your project root (or `~/.claude.json` for all projects):
68
-
69
- ```json
70
- {
71
- "mcpServers": {
72
- "testdriver": {
73
- "type": "stdio",
74
- "command": "npx",
75
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
76
- "env": { "TD_API_KEY": "${TD_API_KEY}" }
77
- }
78
- }
79
- }
80
- ```
81
- </Tab>
82
-
83
- <Tab title="Claude Desktop">
84
- Edit the Claude Desktop config file:
85
-
86
- - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
87
- - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
88
- - **Linux:** `~/.config/Claude/claude_desktop_config.json`
89
-
90
- ```json
91
- {
92
- "mcpServers": {
93
- "testdriver": {
94
- "command": "npx",
95
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
96
- "env": { "TD_API_KEY": "your_api_key" }
97
- }
98
- }
99
- }
100
- ```
101
-
102
- Restart Claude Desktop after saving.
103
- </Tab>
104
-
105
- <Tab title="Cursor">
106
- Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
107
-
108
- ```json
109
- {
110
- "mcpServers": {
111
- "testdriver": {
112
- "type": "stdio",
113
- "command": "npx",
114
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
115
- "env": { "TD_API_KEY": "${TD_API_KEY}" }
116
- }
117
- }
118
- }
119
- ```
120
- </Tab>
121
-
122
- <Tab title="VS Code">
123
- Add to `.vscode/mcp.json`. VS Code uses the `servers` key and an `inputs` prompt for secrets:
124
-
125
- ```json
126
- {
127
- "servers": {
128
- "testdriver": {
129
- "type": "stdio",
130
- "command": "npx",
131
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
132
- "env": { "TD_API_KEY": "${input:testdriver-api-key}" }
133
- }
134
- },
135
- "inputs": [
136
- {
137
- "type": "promptString",
138
- "id": "testdriver-api-key",
139
- "description": "TestDriver API Key From https://console.testdriver.ai/team",
140
- "password": true
141
- }
142
- ]
143
- }
144
- ```
145
- </Tab>
146
-
147
- <Tab title="Windsurf">
148
- Windsurf reads MCP config globally. Add to `~/.codeium/windsurf/mcp_config.json`:
149
-
150
- ```json
151
- {
152
- "mcpServers": {
153
- "testdriver": {
154
- "command": "npx",
155
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
156
- "env": { "TD_API_KEY": "${TD_API_KEY}" }
157
- }
158
- }
159
- }
160
- ```
161
- </Tab>
162
-
163
- <Tab title="Codex">
164
- Codex uses TOML. Add to `~/.codex/config.toml`:
165
-
166
- ```toml
167
- [mcp_servers.testdriver]
168
- command = "npx"
169
- args = ["-p", "testdriverai", "testdriverai-mcp"]
170
- env = { TD_API_KEY = "${TD_API_KEY}" }
171
- ```
172
- </Tab>
173
-
174
- <Tab title="Zed">
175
- Zed calls them "context servers". Add to `.zed/settings.json` (project) or `~/.config/zed/settings.json` (global):
176
-
177
- ```json
178
- {
179
- "context_servers": {
180
- "testdriver": {
181
- "command": "npx",
182
- "args": ["-p", "testdriverai", "testdriverai-mcp"],
183
- "env": { "TD_API_KEY": "${TD_API_KEY}" }
184
- }
185
- }
186
- }
187
- ```
188
- </Tab>
189
- </Tabs>
190
-
191
- ## Web-based clients
192
-
193
- Lovable, Replit, and v0 run in the browser, so the MCP server can't be launched as a local process. Configure them through each product's UI.
194
-
195
- <AccordionGroup>
196
- <Accordion title="Lovable">
197
- 1. Connect your GitHub repo and run `npx testdriverai init --client lovable` — this writes `AGENTS.md` and the skills into the repo so Lovable's agent picks them up.
198
- 2. In Lovable, open **Settings → MCP** and add the TestDriver server.
199
- </Accordion>
200
-
201
- <Accordion title="Replit">
202
- 1. Run `npx testdriverai init --client replit` to write `replit.md` with the TestDriver agent guidance.
203
- 2. In Replit, open **Tools → Integrations → MCP** and add a custom MCP server.
204
- </Accordion>
205
-
206
- <Accordion title="v0 (Vercel)">
207
- v0 is fully UI-driven and does not read repo files.
208
-
209
- 1. Open **[v0.app/chat/settings/mcp-connections](https://v0.app/chat/settings/mcp-connections)** and add the TestDriver MCP connection.
210
- 2. Paste the agent guidance into **Instructions** (the **+** in the prompt bar).
211
- </Accordion>
212
- </AccordionGroup>
213
-
214
- ## Verifying the install
215
-
216
- After installing, open your client's chat and ask the agent to write a test:
217
-
218
- ```text
219
- @testdriver write a test that opens the homepage and asserts the title
220
- ```
221
-
222
- If the MCP server is wired up correctly, the agent will start a session and you'll see screenshots come back as it works. If tools don't appear, check that `TD_API_KEY` is set and restart the client.
223
-
224
- ## Related
225
-
226
- - [Agent](/v7/ai/agent) — the test-creator that uses these tools
227
- - [Skills](/v7/ai/skills) — instruction files describing each tool
228
- - [CI/CD](/v7/ci-cd) — running the generated tests in your pipeline
@@ -1,73 +0,0 @@
1
- ---
2
- title: "Skills"
3
- sidebarTitle: "Skills"
4
- description: "Composable instruction files that teach any AI client how to use TestDriver"
5
- icon: "puzzle-piece"
6
- ---
7
-
8
- ## Overview
9
-
10
- **Skills** are small, focused instruction files — one per TestDriver capability — that teach your AI client exactly how to use each part of the TestDriver SDK and MCP tools. They follow the [Anthropic `SKILL.md` format](https://code.claude.com/docs/en/skills): a folder per skill, each containing a `SKILL.md` with YAML frontmatter and a markdown body.
11
-
12
- There are **106 skills**, generated directly from the TestDriver documentation, covering every action and concept: `find`, `click`, `type`, `assert`, `check`, `scroll`, `press-keys`, `provision`, caching, secrets, CI/CD, and more.
13
-
14
- ```text
15
- .claude/skills/
16
- ├── testdriver-click/
17
- │ └── SKILL.md
18
- ├── testdriver-find/
19
- │ └── SKILL.md
20
- ├── testdriver-assert/
21
- │ └── SKILL.md
22
- └── … (103 more)
23
- ```
24
-
25
- Each `SKILL.md` looks like:
26
-
27
- ```markdown
28
- ---
29
- name: testdriver:click
30
- description: Click at specific coordinates or on elements
31
- ---
32
-
33
- ## Element Click
34
-
35
- When called on an Element object, clicks on the located element.
36
-
37
- ```
38
-
39
- ## Why skills
40
-
41
- The [agent](/v7/ai/agent) is general; skills are specific. When the agent needs to perform an action — say, locate an element — it pulls in the `testdriver:find` skill, which contains the exact syntax, options, return shape, and gotchas for that one method. This keeps the agent accurate without bloating its base prompt, and lets clients load only the skills relevant to the current step.
42
-
43
- ## Installation
44
-
45
- Skills are installed by `testdriverai init` along with the [agent](/v7/ai/agent) and [MCP server](/v7/ai/mcp):
46
-
47
- ```bash
48
- npx testdriverai init
49
- ```
50
-
51
- They're written to the skills directory each client expects:
52
-
53
- | Client | Skills location |
54
- | --- | --- |
55
- | Claude Code | `.claude/skills/<name>/SKILL.md` |
56
- | Zed | `.agents/skills/<name>/SKILL.md` |
57
- | Codex | referenced from `AGENTS.md` |
58
- | VS Code · Cursor · Windsurf | folded into the agent rules/instructions |
59
-
60
- Clients without a native skills concept (Cursor, VS Code, Windsurf) still get the agent definition, which references the same guidance inline.
61
-
62
- ## Authoring & regenerating
63
-
64
- Skills are **generated, not hand-edited** — each is built from a `.mdx` page in the docs. Do not edit `SKILL.md` files directly (they carry a `DO NOT EDIT` marker). To change a skill, edit the corresponding documentation page and regenerate:
65
-
66
- ```bash
67
- node docs/_scripts/generate-skills.js
68
- ```
69
-
70
- ## Related
71
-
72
- - [Agent](/v7/ai/agent) — composes skills into working tests
73
- - [MCP Server](/v7/ai/mcp) — the tools the skills describe how to use
package/docs/v7/ai.mdx DELETED
@@ -1,205 +0,0 @@
1
- ---
2
- title: "ai()"
3
- sidebarTitle: "ai"
4
- description: "Execute natural language tasks using AI"
5
- icon: "wand-magic-sparkles"
6
- ---
7
-
8
- ## Overview
9
-
10
- The `ai()` method allows you to execute complex tasks using natural language descriptions. TestDriver's AI will figure out the steps needed to accomplish the task.
11
-
12
- ## Syntax
13
-
14
- ```javascript
15
- await testdriver.ai(task, options)
16
- ```
17
-
18
- ## Parameters
19
-
20
- <ParamField path="task" type="string" required>
21
- Natural language description of what to do
22
- </ParamField>
23
-
24
- <ParamField path="options" type="object">
25
- Execution options
26
-
27
- <Expandable title="properties">
28
- <ParamField path="validateAndLoop" type="boolean" default="false">
29
- Whether to validate completion and retry if incomplete
30
- </ParamField>
31
- </Expandable>
32
- </ParamField>
33
-
34
- ## Returns
35
-
36
- `Promise<string | void>` - Final AI response if `validateAndLoop` is true
37
-
38
- ## Examples
39
-
40
- ### Basic Usage
41
-
42
- ```javascript
43
- // Simple task execution
44
- await testdriver.ai('Click the submit button');
45
-
46
- // Complex multi-step task
47
- await testdriver.ai('Fill out the contact form and submit it');
48
-
49
- // Navigation task
50
- await testdriver.ai('Go to the settings page and enable notifications');
51
- ```
52
-
53
- ### With Validation
54
-
55
- ```javascript
56
- // AI will verify the task completed successfully
57
- const result = await testdriver.ai('Complete the checkout process', {
58
- validateAndLoop: true
59
- });
60
-
61
- console.log('Task result:', result);
62
- ```
63
-
64
- ### Multi-Step Workflows
65
-
66
- ```javascript
67
- // The AI will break down complex tasks
68
- await testdriver.ai('Search for "laptop", add the first result to cart, and proceed to checkout');
69
-
70
- // UI exploration
71
- await testdriver.ai('Find and click all menu items to explore the application');
72
- ```
73
-
74
- ## Use Cases
75
-
76
- <AccordionGroup>
77
- <Accordion title="Exploratory Testing">
78
- Use AI to explore unfamiliar applications:
79
-
80
- ```javascript
81
- await testdriver.ai('Explore the main navigation menu');
82
- await testdriver.ai('Try to find the user profile settings');
83
- ```
84
- </Accordion>
85
-
86
- <Accordion title="Complex Workflows">
87
- Let AI handle multi-step processes:
88
-
89
- ```javascript
90
- await testdriver.ai('Complete the multi-step registration form');
91
- await testdriver.ai('Configure all the advanced settings to default values');
92
- ```
93
- </Accordion>
94
-
95
- <Accordion title="Flexible Interactions">
96
- When exact element locations aren't critical:
97
-
98
- ```javascript
99
- await testdriver.ai('Close any popup dialogs');
100
- await testdriver.ai('Accept the cookie consent if it appears');
101
- ```
102
- </Accordion>
103
- </AccordionGroup>
104
-
105
- ## Best Practices
106
-
107
- <Check>
108
- **Be specific but flexible**: Give enough context without over-constraining the AI
109
-
110
- ```javascript
111
- // ✅ Good
112
- await testdriver.ai('Add the first product to the shopping cart');
113
-
114
- // ❌ Too vague
115
- await testdriver.ai('do something');
116
-
117
- // ❌ Too specific (defeats the purpose)
118
- await testdriver.ai('click at coordinates 500, 300');
119
- ```
120
- </Check>
121
-
122
- <Check>
123
- **Use for exploration, not precision**: For critical assertions, use explicit methods
124
-
125
- ```javascript
126
- // Use AI for setup
127
- await testdriver.ai('Navigate to the login page');
128
-
129
- // Use explicit methods for critical steps
130
- const usernameField = await testdriver.find('username input');
131
- await usernameField.click();
132
- await testdriver.type('testuser');
133
-
134
- await testdriver.assert('login page is displayed');
135
- ```
136
- </Check>
137
-
138
- <Warning>
139
- **AI tasks may be slower**: The AI needs to analyze the screen and plan actions. For performance-critical tests, use explicit methods.
140
- </Warning>
141
-
142
- ## When to Use AI vs Explicit Methods
143
-
144
- ### Use `ai()` when:
145
- - Exploring unfamiliar applications
146
- - Handling optional UI elements (popups, cookies, etc.)
147
- - Prototyping tests quickly
148
- - Tasks where exact steps may vary
149
-
150
- ### Use explicit methods when:
151
- - Performance is critical
152
- - You need precise control
153
- - Making assertions
154
- - Debugging test failures
155
- - Repetitive, predictable actions
156
-
157
- ## Complete Example
158
-
159
- ```javascript
160
- import { beforeAll, afterAll, describe, it } from 'vitest';
161
- import TestDriver from 'testdriverai';
162
-
163
- describe('E-commerce Flow with AI', () => {
164
- let testdriver;
165
-
166
- beforeAll(async () => {
167
- client = new TestDriver(process.env.TD_API_KEY);
168
- await testdriver.auth();
169
- await testdriver.connect();
170
- });
171
-
172
- afterAll(async () => {
173
- await testdriver.disconnect();
174
- });
175
-
176
- it('should complete shopping flow using AI assistance', async () => {
177
- await testdriver.focusApplication('Google Chrome');
178
-
179
- // Use AI for navigation and exploration
180
- await testdriver.ai('Browse to the electronics section');
181
- await testdriver.ai('Find and add a laptop to the cart');
182
-
183
- // Use explicit methods for critical steps
184
- const cartIcon = await testdriver.find('shopping cart icon');
185
- await cartIcon.click();
186
-
187
- const total = await testdriver.extract('the cart total amount');
188
- console.log('Cart total:', total);
189
-
190
- // Use AI for checkout flow
191
- await testdriver.ai('Proceed to checkout and fill in shipping details', {
192
- validateAndLoop: true
193
- });
194
-
195
- // Explicit assertion
196
- await testdriver.assert('order confirmation page is displayed');
197
- });
198
- });
199
- ```
200
-
201
- ## Related Methods
202
-
203
- - [`find()`](/v7/find) - Locate specific elements
204
- - [`assert()`](/v7/assert) - Make assertions
205
- - [`extract()`](/v7/extract) - Extract information
@@ -1,156 +0,0 @@
1
- ---
2
- title: "Creating Tests"
3
- sidebarTitle: "Creating Tests"
4
- description: "Use the TestDriver agent and MCP to create tests through natural language"
5
- icon: "wand-magic-sparkles"
6
- ---
7
-
8
- With GitHub Copilot and TestDriver's MCP server, you can create tests by chatting with an AI agent. The agent spawns a virtual machine, executes actions, and writes test code for you.
9
-
10
- ## Start a Conversation
11
-
12
- Open GitHub Copilot Chat in VS Code. If your project has no other agents configured, the TestDriver agent is used by default. Otherwise, select **testdriver** from the agent dropdown in the chat panel.
13
-
14
- Describe what you want to test:
15
-
16
- ```
17
- Create a test that logs into my app at https://myapp.com
18
- ```
19
-
20
- The agent will:
21
- 1. Start a new session and spawn a Linux virtual machine
22
- 2. Launch Chrome and navigate to your URL
23
- 3. Execute actions based on your instructions
24
- 4. Write the test code to a `.test.mjs` file
25
-
26
- <Note>
27
- The TestDriver agent appears in the agent selection dropdown if you have other agents configured (like `copilot-instructions.md` or other `.agent.md` files). Make sure to select **testdriver** to use TestDriver's MCP tools.
28
- </Note>
29
-
30
- ## Live Preview Panel
31
-
32
- When the agent starts a session, a **live preview panel** opens in VS Code. This lets you:
33
-
34
- - **Watch tests execute** in real-time
35
- - **Interact with the VM** — click, type, and navigate manually
36
- - **Debug issues** — see exactly what the AI sees
37
-
38
- <Note>
39
- The live preview panel requires the TestDriver VS Code extension. Set `TD_PREVIEW=ide` in your MCP configuration to enable it. See the [device configuration docs](/v7/device-config) for all preview options.
40
- </Note>
41
-
42
- ## Interactive Workflow
43
-
44
- The recommended workflow for creating tests:
45
-
46
- <Steps>
47
- <Step title="Describe Your Test">
48
- Tell the agent what you want to test:
49
-
50
- ```
51
- Test the checkout flow on https://shop.example.com
52
- ```
53
- </Step>
54
-
55
- <Step title="Watch and Guide">
56
- The agent will start executing. Watch the preview panel and provide guidance if needed:
57
-
58
- ```
59
- The login modal appeared. Use test@example.com and password123
60
- ```
61
- </Step>
62
-
63
- <Step title="Add Assertions">
64
- Ask the agent to verify specific conditions:
65
-
66
- ```
67
- Assert that the order confirmation page is shown with the order number
68
- ```
69
- </Step>
70
-
71
- <Step title="Review the Code">
72
- The agent writes test code as it works. Review the generated `.test.mjs` file and make any adjustments.
73
- </Step>
74
- </Steps>
75
-
76
- ## Example Conversation
77
-
78
- Here's a complete example of creating a login test:
79
-
80
- ```
81
- You: Create a test for the login flow at https://console.testdriver.ai
82
-
83
- Agent: I'll create a test for the login flow. Starting a session...
84
- [Screenshot: Login page loaded]
85
-
86
- I can see the login page. Let me find the email input.
87
- [Screenshot: Email input highlighted]
88
-
89
- Now I'll type the email and find the password field...
90
-
91
- You: Use test@example.com for the email
92
-
93
- Agent: Got it. Typing test@example.com...
94
- [Screenshot: Email entered]
95
-
96
- Now entering the password and clicking Sign In...
97
- [Screenshot: Dashboard loaded]
98
-
99
- ✅ Login successful! I've written the test to tests/login.test.mjs
100
- ```
101
-
102
- ## Generated Test Code
103
-
104
- The agent generates standard Vitest test files:
105
-
106
- ```javascript tests/login.test.mjs
107
- import { describe, expect, it } from "vitest";
108
- import { TestDriver } from "testdriverai/vitest/hooks";
109
-
110
- describe("Login Flow", () => {
111
- it("should log in successfully", async (context) => {
112
- const testdriver = TestDriver(context);
113
-
114
- await testdriver.provision.chrome({
115
- url: "https://console.testdriver.ai"
116
- });
117
-
118
- const emailInput = await testdriver.find("email input field");
119
- await emailInput.click();
120
- await testdriver.type("test@example.com");
121
-
122
- const passwordInput = await testdriver.find("password input field");
123
- await passwordInput.click();
124
- await testdriver.type("password123");
125
-
126
- const signInButton = await testdriver.find("Sign In button");
127
- await signInButton.click();
128
-
129
- const result = await testdriver.assert("dashboard is visible");
130
- expect(result).toBeTruthy();
131
- });
132
- });
133
- ```
134
-
135
- ## Tips for Better Tests
136
-
137
- <AccordionGroup>
138
- <Accordion title="Be specific with element descriptions">
139
- Instead of "click the button", say "click the blue Sign In button in the header". More context helps the AI find the right element.
140
- </Accordion>
141
- <Accordion title="Add waits for dynamic content">
142
- If your app has animations or loading states, tell the agent to wait:
143
- ```
144
- Wait for the loading spinner to disappear before continuing
145
- ```
146
- </Accordion>
147
- <Accordion title="Use assertions liberally">
148
- Add assertions after each major action to catch regressions early:
149
- ```
150
- Assert that the product was added to the cart
151
- ```
152
- </Accordion>
153
- <Accordion title="Break complex flows into steps">
154
- For long workflows, create the test incrementally and verify each step works before moving on.
155
- </Accordion>
156
- </AccordionGroup>