@testdriverai/agent 7.11.240-test → 7.11.241-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.
- package/ai/skills/testdriver-agent/SKILL.md +174 -91
- package/ai/skills/testdriver-assert/SKILL.md +73 -269
- package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
- package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
- package/ai/skills/testdriver-cache/SKILL.md +142 -149
- package/ai/skills/testdriver-caching/SKILL.md +97 -87
- package/ai/skills/testdriver-captcha/SKILL.md +126 -111
- package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
- package/ai/skills/testdriver-click/SKILL.md +74 -229
- package/ai/skills/testdriver-client/SKILL.md +175 -229
- package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
- package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
- package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
- package/ai/skills/testdriver-double-click/SKILL.md +46 -67
- package/ai/skills/testdriver-errors/SKILL.md +102 -176
- package/ai/skills/testdriver-events/SKILL.md +170 -327
- package/ai/skills/testdriver-exec/SKILL.md +92 -256
- package/ai/skills/testdriver-extract/SKILL.md +69 -170
- package/ai/skills/testdriver-find/SKILL.md +140 -736
- package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
- package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
- package/ai/skills/testdriver-hosted/SKILL.md +79 -143
- package/ai/skills/testdriver-hover/SKILL.md +62 -235
- package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
- package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
- package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
- package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
- package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
- package/ai/skills/testdriver-options/SKILL.md +73 -46
- package/ai/skills/testdriver-parse/SKILL.md +95 -184
- package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
- package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
- package/ai/skills/testdriver-provision/SKILL.md +135 -179
- package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
- package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
- package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
- package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
- package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
- package/ai/skills/testdriver-redraw/SKILL.md +100 -164
- package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
- package/ai/skills/testdriver-right-click/SKILL.md +45 -88
- package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
- package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
- package/ai/skills/testdriver-scroll/SKILL.md +71 -154
- package/ai/skills/testdriver-secrets/SKILL.md +94 -90
- package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
- package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
- package/ai/skills/testdriver-type/SKILL.md +56 -304
- package/ai/skills/testdriver-variables/SKILL.md +119 -80
- package/ai/skills/testdriver-wait/SKILL.md +31 -29
- package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
- package/package.json +1 -1
|
@@ -1,314 +1,118 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: testdriver:assert
|
|
3
|
-
description:
|
|
3
|
+
description: Check a plain-language statement about the screen, and fail the test if it's false.
|
|
4
4
|
---
|
|
5
5
|
<!-- Generated from assert.mdx. DO NOT EDIT. -->
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Check that something is true on screen. The AI looks at the current screen and decides whether your statement holds.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```javascript
|
|
10
|
+
await testdriver.assert('the dashboard shows a welcome message');
|
|
11
|
+
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
For writing good assertions, see [Make assertions](/making-assertions).
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
## Signature
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
testdriver.assert(assertion: string, options?: AssertOptions): Promise<boolean>
|
|
16
19
|
```
|
|
17
20
|
|
|
18
21
|
## Parameters
|
|
19
22
|
|
|
20
23
|
<ParamField path="assertion" type="string" required>
|
|
21
|
-
|
|
24
|
+
A statement about the screen that should be true, such as `'the cart shows 1 item'`.
|
|
22
25
|
</ParamField>
|
|
23
26
|
|
|
24
|
-
<ParamField path="options" type="
|
|
25
|
-
Optional configuration
|
|
26
|
-
|
|
27
|
+
<ParamField path="options" type="AssertOptions">
|
|
27
28
|
<Expandable title="properties">
|
|
28
|
-
<ParamField path="
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</ParamField>
|
|
43
|
-
|
|
44
|
-
<ParamField path="k" type="number">
|
|
45
|
-
Top-K sampling. `1` = most deterministic.
|
|
46
|
-
</ParamField>
|
|
47
|
-
</Expandable>
|
|
48
|
-
</ParamField>
|
|
49
|
-
</Expandable>
|
|
29
|
+
<ParamField path="threshold" type="number" default="0.05">
|
|
30
|
+
How much the screen may differ from a cached passing run (0 to 1) and still reuse its result. Defaults to the client's `cache.thresholds.assert`, which is `0.05`. `-1` turns caching off for this call. See [Caching](/caching).
|
|
31
|
+
</ParamField>
|
|
32
|
+
<ParamField path="cacheKey" type="string">
|
|
33
|
+
Store and look up the cached result under this key instead of the client's.
|
|
34
|
+
</ParamField>
|
|
35
|
+
<ParamField path="ai" type="AIConfig">
|
|
36
|
+
Sampling settings for this call, such as `{ temperature: 0 }`. Overrides the client's [`ai` option](/options#param-ai).
|
|
37
|
+
</ParamField>
|
|
38
|
+
<ParamField path="os" type="string">
|
|
39
|
+
The OS to store the cached result under. Set automatically from the client.
|
|
40
|
+
</ParamField>
|
|
41
|
+
<ParamField path="resolution" type="string">
|
|
42
|
+
The resolution to store the cached result under. Set automatically from the client.
|
|
50
43
|
</ParamField>
|
|
51
44
|
</Expandable>
|
|
52
45
|
</ParamField>
|
|
53
46
|
|
|
54
47
|
## Returns
|
|
55
48
|
|
|
56
|
-
`Promise<boolean
|
|
49
|
+
`Promise<boolean>`. Resolves to `true` when the statement is true.
|
|
50
|
+
|
|
51
|
+
## Errors
|
|
52
|
+
|
|
53
|
+
When the statement is false, `assert()` throws, so the test fails at that line. The error message starts with `AI Assertion failed:`, followed by your statement and the AI's explanation.
|
|
54
|
+
|
|
55
|
+
Inside `ai()`, assertions don't throw. They resolve to `false` so the AI can keep working.
|
|
57
56
|
|
|
58
57
|
## Examples
|
|
59
58
|
|
|
60
|
-
###
|
|
59
|
+
### Check the result of an action
|
|
61
60
|
|
|
62
61
|
```javascript
|
|
63
|
-
|
|
64
|
-
await testdriver.assert('the
|
|
65
|
-
await testdriver.assert('submit button is visible');
|
|
66
|
-
await testdriver.assert('error message is shown');
|
|
67
|
-
|
|
68
|
-
// Verify text content
|
|
69
|
-
await testdriver.assert('the page title is "Welcome"');
|
|
70
|
-
await testdriver.assert('username field contains "john.doe"');
|
|
71
|
-
await testdriver.assert('success message says "Account created"');
|
|
72
|
-
|
|
73
|
-
// Verify states
|
|
74
|
-
await testdriver.assert('the form is empty');
|
|
75
|
-
await testdriver.assert('the checkbox is checked');
|
|
76
|
-
await testdriver.assert('the dropdown shows "United States"');
|
|
77
|
-
|
|
78
|
-
// Verify visual appearance
|
|
79
|
-
await testdriver.assert('the button is blue');
|
|
80
|
-
await testdriver.assert('the loading spinner is displayed');
|
|
81
|
-
await testdriver.assert('the modal dialog is open');
|
|
62
|
+
await testdriver.find('Add to cart button').click();
|
|
63
|
+
await testdriver.assert('the cart icon shows 1 item');
|
|
82
64
|
```
|
|
83
65
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<Check>
|
|
87
|
-
**Be specific in assertions**
|
|
88
|
-
|
|
89
|
-
More specific assertions are more reliable:
|
|
90
|
-
|
|
91
|
-
```javascript
|
|
92
|
-
// ❌ Too vague
|
|
93
|
-
await testdriver.assert('button is visible');
|
|
94
|
-
|
|
95
|
-
// ✅ Specific
|
|
96
|
-
await testdriver.assert('blue submit button is visible below the form');
|
|
97
|
-
```
|
|
98
|
-
</Check>
|
|
99
|
-
|
|
100
|
-
<Check>
|
|
101
|
-
**Assert state changes**
|
|
102
|
-
|
|
103
|
-
Make sure of the state before and after actions:
|
|
104
|
-
|
|
105
|
-
```javascript
|
|
106
|
-
// Before
|
|
107
|
-
await testdriver.assert('cart is empty');
|
|
108
|
-
|
|
109
|
-
// Action
|
|
110
|
-
const addBtn = await testdriver.find('add to cart');
|
|
111
|
-
await addBtn.click();
|
|
112
|
-
|
|
113
|
-
// After
|
|
114
|
-
await testdriver.assert('cart contains 1 item');
|
|
115
|
-
```
|
|
116
|
-
</Check>
|
|
117
|
-
|
|
118
|
-
<Check>
|
|
119
|
-
**Use with test framework assertions**
|
|
120
|
-
|
|
121
|
-
Combine AI assertions with traditional test assertions:
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
// AI assertion
|
|
125
|
-
const result = await testdriver.assert('success message is displayed');
|
|
126
|
-
|
|
127
|
-
// Framework assertion
|
|
128
|
-
expect(result).toBeTruthy();
|
|
129
|
-
|
|
130
|
-
// Extract for detailed comparison
|
|
131
|
-
const message = await testdriver.extract('the success message text');
|
|
132
|
-
expect(message).toContain('successfully');
|
|
133
|
-
```
|
|
134
|
-
</Check>
|
|
135
|
-
|
|
136
|
-
## Polling Assertions
|
|
137
|
-
|
|
138
|
-
For conditions that may take time to become true:
|
|
66
|
+
### Check text in a field
|
|
139
67
|
|
|
140
68
|
```javascript
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
while (Date.now() - startTime < timeout) {
|
|
145
|
-
try {
|
|
146
|
-
await testdriver.assert(assertion);
|
|
147
|
-
return true; // Assertion passed
|
|
148
|
-
} catch (error) {
|
|
149
|
-
// Assertion failed, wait and retry
|
|
150
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
throw new Error(`Assertion timeout: "${assertion}"`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Usage
|
|
158
|
-
await waitForAssertion(testdriver, 'page has finished loading', 30000);
|
|
159
|
-
await waitForAssertion(testdriver, 'results are displayed', 10000);
|
|
69
|
+
await testdriver.find('Username input field').click();
|
|
70
|
+
await testdriver.type('standard_user');
|
|
71
|
+
await testdriver.assert('the username field contains "standard_user"');
|
|
160
72
|
```
|
|
161
73
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<Accordion title="Form Validation">
|
|
166
|
-
```javascript
|
|
167
|
-
// Try to submit empty form
|
|
168
|
-
const submitBtn = await testdriver.find('submit button');
|
|
169
|
-
await submitBtn.click();
|
|
170
|
-
|
|
171
|
-
// Verify validation errors
|
|
172
|
-
await testdriver.assert('email field shows "required" error');
|
|
173
|
-
await testdriver.assert('password field shows "required" error');
|
|
174
|
-
|
|
175
|
-
// Verify form not submitted
|
|
176
|
-
await testdriver.assert('still on the form page');
|
|
177
|
-
```
|
|
178
|
-
</Accordion>
|
|
179
|
-
|
|
180
|
-
<Accordion title="Page Navigation">
|
|
181
|
-
```javascript
|
|
182
|
-
const loginBtn = await testdriver.find('login button');
|
|
183
|
-
await loginBtn.click();
|
|
184
|
-
|
|
185
|
-
// Verify navigation
|
|
186
|
-
await testdriver.assert('user dashboard is displayed');
|
|
187
|
-
await testdriver.assert('welcome message shows user name');
|
|
188
|
-
await testdriver.assert('logout button is visible');
|
|
189
|
-
```
|
|
190
|
-
</Accordion>
|
|
191
|
-
|
|
192
|
-
<Accordion title="Dynamic Content">
|
|
193
|
-
```javascript
|
|
194
|
-
const loadBtn = await testdriver.find('load more button');
|
|
195
|
-
await loadBtn.click();
|
|
196
|
-
|
|
197
|
-
// Poll for content using helper
|
|
198
|
-
await waitForAssertion(testdriver, 'more than 10 items are shown', 10000);
|
|
199
|
-
await testdriver.assert('load more button is still visible');
|
|
200
|
-
```
|
|
201
|
-
</Accordion>
|
|
202
|
-
|
|
203
|
-
<Accordion title="Visual States">
|
|
204
|
-
```javascript
|
|
205
|
-
// Verify hover effect
|
|
206
|
-
const button = await testdriver.find('primary button');
|
|
207
|
-
await button.hover();
|
|
208
|
-
|
|
209
|
-
await testdriver.assert('button background is darker');
|
|
210
|
-
|
|
211
|
-
// Verify button is enabled
|
|
212
|
-
await testdriver.assert('submit button is enabled');
|
|
213
|
-
```
|
|
214
|
-
</Accordion>
|
|
215
|
-
|
|
216
|
-
<Accordion title="Multi-Step Workflows">
|
|
217
|
-
```javascript
|
|
218
|
-
// Step 1
|
|
219
|
-
await testdriver.assert('step 1 is active');
|
|
220
|
-
const nextBtn = await testdriver.find('next button');
|
|
221
|
-
await nextBtn.click();
|
|
222
|
-
|
|
223
|
-
// Step 2
|
|
224
|
-
await testdriver.assert('step 2 is active');
|
|
225
|
-
await testdriver.assert('step 1 is completed');
|
|
226
|
-
await nextBtn.click();
|
|
227
|
-
|
|
228
|
-
// Step 3
|
|
229
|
-
await testdriver.assert('step 3 is active');
|
|
230
|
-
await testdriver.assert('step 2 is completed');
|
|
231
|
-
```
|
|
232
|
-
</Accordion>
|
|
233
|
-
</AccordionGroup>
|
|
234
|
-
|
|
235
|
-
## Complete Example
|
|
74
|
+
### Use it with expect()
|
|
75
|
+
|
|
76
|
+
`assert()` already fails the test when the statement is false. An `expect()` makes the check visible to anyone reading the test:
|
|
236
77
|
|
|
237
78
|
```javascript
|
|
238
|
-
|
|
239
|
-
|
|
79
|
+
const loggedIn = await testdriver.assert('the dashboard is visible');
|
|
80
|
+
expect(loggedIn).toBe(true);
|
|
81
|
+
```
|
|
240
82
|
|
|
241
|
-
|
|
242
|
-
let testdriver;
|
|
83
|
+
### Wait for something before asserting
|
|
243
84
|
|
|
244
|
-
|
|
245
|
-
client = new TestDriver(process.env.TD_API_KEY);
|
|
246
|
-
await testdriver.auth();
|
|
247
|
-
await testdriver.connect();
|
|
248
|
-
});
|
|
85
|
+
`assert()` checks the screen once. For something that takes time to appear, wait for it with [`find()`](/find) first:
|
|
249
86
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
87
|
+
```javascript
|
|
88
|
+
await testdriver.find('Order confirmation heading', { timeout: 30000 });
|
|
89
|
+
await testdriver.assert('the confirmation shows an order number');
|
|
90
|
+
```
|
|
253
91
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
await testdriver.
|
|
266
|
-
|
|
267
|
-
await testdriver.
|
|
268
|
-
await testdriver.type('password123');
|
|
269
|
-
|
|
270
|
-
// Verify fields filled
|
|
271
|
-
await testdriver.assert('username field contains "testuser"');
|
|
272
|
-
await testdriver.assert('password field is not empty');
|
|
273
|
-
|
|
274
|
-
// Submit
|
|
275
|
-
await testdriver.pressKeys(['enter']);
|
|
276
|
-
|
|
277
|
-
// Poll for success
|
|
278
|
-
await waitForAssertion(testdriver, 'user dashboard is displayed', 10000);
|
|
279
|
-
|
|
280
|
-
// Verify logged in state
|
|
281
|
-
await testdriver.assert('welcome message is shown');
|
|
282
|
-
await testdriver.assert('logout button is visible');
|
|
283
|
-
|
|
284
|
-
// Verify login page is gone
|
|
285
|
-
await testdriver.assert('login form is displayed', false, true);
|
|
286
|
-
});
|
|
92
|
+
## Complete example
|
|
93
|
+
|
|
94
|
+
```javascript tests/login.test.mjs
|
|
95
|
+
import { describe, expect, it } from 'vitest';
|
|
96
|
+
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
97
|
+
|
|
98
|
+
describe('Login', () => {
|
|
99
|
+
it('shows an error when the form is empty', async (context) => {
|
|
100
|
+
const testdriver = TestDriver(context);
|
|
101
|
+
await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
|
|
102
|
+
|
|
103
|
+
await testdriver.assert('the login form is empty');
|
|
104
|
+
|
|
105
|
+
await testdriver.find('Sign in button below the password field').click();
|
|
287
106
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const submitBtn = await testdriver.find('submit button');
|
|
291
|
-
await submitBtn.click();
|
|
292
|
-
|
|
293
|
-
// Verify multiple errors
|
|
294
|
-
const errors = [
|
|
295
|
-
'email field shows error',
|
|
296
|
-
'name field shows error',
|
|
297
|
-
'password field shows error'
|
|
298
|
-
];
|
|
299
|
-
|
|
300
|
-
for (const error of errors) {
|
|
301
|
-
const result = await testdriver.assert(error);
|
|
302
|
-
expect(result).toBeTruthy();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Verify not submitted
|
|
306
|
-
await testdriver.assert('confirmation page is shown', false, true);
|
|
107
|
+
const result = await testdriver.assert('an error says the fields are required');
|
|
108
|
+
expect(result).toBe(true);
|
|
307
109
|
});
|
|
308
110
|
});
|
|
309
111
|
```
|
|
310
112
|
|
|
311
|
-
## Related
|
|
113
|
+
## Related
|
|
312
114
|
|
|
313
|
-
- [
|
|
314
|
-
- [
|
|
115
|
+
- [Make assertions](/making-assertions): write assertions that catch real regressions
|
|
116
|
+
- [extract()](/extract): read a value off the screen to compare yourself
|
|
117
|
+
- [find()](/find): wait for an element before asserting
|
|
118
|
+
- [Caching](/caching): how assertion results are reused
|