@testdriverai/agent 7.11.239-test → 7.11.241-canary

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 (52) hide show
  1. package/ai/skills/testdriver-agent/SKILL.md +174 -91
  2. package/ai/skills/testdriver-assert/SKILL.md +73 -269
  3. package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
  4. package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
  5. package/ai/skills/testdriver-cache/SKILL.md +142 -149
  6. package/ai/skills/testdriver-caching/SKILL.md +97 -87
  7. package/ai/skills/testdriver-captcha/SKILL.md +126 -111
  8. package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
  9. package/ai/skills/testdriver-click/SKILL.md +74 -229
  10. package/ai/skills/testdriver-client/SKILL.md +175 -229
  11. package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
  12. package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
  13. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
  14. package/ai/skills/testdriver-double-click/SKILL.md +46 -67
  15. package/ai/skills/testdriver-errors/SKILL.md +102 -176
  16. package/ai/skills/testdriver-events/SKILL.md +170 -327
  17. package/ai/skills/testdriver-exec/SKILL.md +92 -256
  18. package/ai/skills/testdriver-extract/SKILL.md +69 -170
  19. package/ai/skills/testdriver-find/SKILL.md +140 -736
  20. package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
  22. package/ai/skills/testdriver-hosted/SKILL.md +79 -143
  23. package/ai/skills/testdriver-hover/SKILL.md +62 -235
  24. package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
  25. package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
  26. package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
  27. package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
  28. package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
  29. package/ai/skills/testdriver-options/SKILL.md +73 -46
  30. package/ai/skills/testdriver-parse/SKILL.md +95 -184
  31. package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
  32. package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
  33. package/ai/skills/testdriver-provision/SKILL.md +135 -179
  34. package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
  35. package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
  36. package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
  37. package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
  38. package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
  39. package/ai/skills/testdriver-redraw/SKILL.md +100 -164
  40. package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
  41. package/ai/skills/testdriver-right-click/SKILL.md +45 -88
  42. package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
  43. package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
  44. package/ai/skills/testdriver-scroll/SKILL.md +71 -154
  45. package/ai/skills/testdriver-secrets/SKILL.md +94 -90
  46. package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
  47. package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
  48. package/ai/skills/testdriver-type/SKILL.md +56 -304
  49. package/ai/skills/testdriver-variables/SKILL.md +119 -80
  50. package/ai/skills/testdriver-wait/SKILL.md +31 -29
  51. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
  52. package/package.json +1 -1
@@ -1,314 +1,118 @@
1
1
  ---
2
2
  name: testdriver:assert
3
- description: Make AI-powered assertions about screen state
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
- ## Overview
7
+ Check that something is true on screen. The AI looks at the current screen and decides whether your statement holds.
8
8
 
9
- Make assertions about the screen state with natural language and AI. The AI examines the screen. It makes sure that your assertion is true.
9
+ ```javascript
10
+ await testdriver.assert('the dashboard shows a welcome message');
11
+ ```
10
12
 
11
- ## Syntax
13
+ For writing good assertions, see [Make assertions](/making-assertions).
12
14
 
13
- ```javascript
14
- await testdriver.assert(assertion)
15
- await testdriver.assert(assertion, options)
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
- Natural language description of what should be true
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="object">
25
- Optional configuration
26
-
27
+ <ParamField path="options" type="AssertOptions">
27
28
  <Expandable title="properties">
28
- <ParamField path="ai" type="object">
29
- AI sampling configuration for this assert call (overrides global `ai` config from constructor).
30
-
31
- <Expandable title="properties">
32
- <ParamField path="temperature" type="number">
33
- Controls randomness. `0` = deterministic, higher = more creative. Default: model default.
34
- </ParamField>
35
-
36
- <ParamField path="top" type="object">
37
- Sampling parameters
38
-
39
- <Expandable title="properties">
40
- <ParamField path="p" type="number">
41
- Top-P (nucleus sampling). Range: 0-1.
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>` - `true` if the assertion passes. It throws an error if the assertion fails.
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
- ### Basic Assertions
59
+ ### Check the result of an action
61
60
 
62
61
  ```javascript
63
- // Verify page elements
64
- await testdriver.assert('the login page is displayed');
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
- ## Best Practices
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
- async function waitForAssertion(testdriver, assertion, timeout = 30000) {
142
- const startTime = Date.now();
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
- ## Use Cases
163
-
164
- <AccordionGroup>
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
- import { beforeAll, afterAll, describe, it, expect } from 'vitest';
239
- import TestDriver from 'testdriverai';
79
+ const loggedIn = await testdriver.assert('the dashboard is visible');
80
+ expect(loggedIn).toBe(true);
81
+ ```
240
82
 
241
- describe('Assertions', () => {
242
- let testdriver;
83
+ ### Wait for something before asserting
243
84
 
244
- beforeAll(async () => {
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
- afterAll(async () => {
251
- await testdriver.disconnect();
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
- it('should validate login flow', async () => {
255
- await testdriver.focusApplication('Google Chrome');
256
-
257
- // Verify initial state
258
- await testdriver.assert('the login page is displayed');
259
- await testdriver.assert('username field is empty');
260
- await testdriver.assert('password field is empty');
261
-
262
- // Fill form
263
- const usernameField = await testdriver.find('username input');
264
- await usernameField.click();
265
- await testdriver.type('testuser');
266
-
267
- await testdriver.pressKeys(['tab']);
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
- it('should show validation errors', async () => {
289
- // Try empty submission
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 Methods
113
+ ## Related
312
114
 
313
- - [`extract()`](/extract) - Extract information for detailed assertions
314
- - [`find()`](/find) - Locate elements to verify
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