testdriverai 7.2.9 → 7.2.11
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/.github/workflows/testdriver.yml +127 -0
- package/.testdriver/last-sandbox +7 -0
- package/agent/events.js +1 -0
- package/agent/index.js +71 -54
- package/agent/lib/sandbox.js +11 -1
- package/agents.md +393 -0
- package/debug/01-table-initial.png +0 -0
- package/debug/02-after-ai-explore.png +0 -0
- package/debug/02-after-scroll.png +0 -0
- package/docs/docs.json +87 -126
- package/docs/v7/_drafts/caching.mdx +2 -2
- package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
- package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
- package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
- package/docs/v7/_drafts/screenshot.mdx +155 -0
- package/docs/v7/_drafts/writing-tests.mdx +25 -0
- package/docs/v7/{api/act.mdx → ai.mdx} +27 -27
- package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
- package/docs/v7/aws-setup.mdx +338 -0
- package/docs/v7/caching.mdx +128 -0
- package/docs/v7/ci-cd.mdx +605 -0
- package/docs/v7/{api/click.mdx → click.mdx} +4 -4
- package/docs/v7/cloud.mdx +120 -0
- package/docs/v7/customizing-devices.mdx +129 -0
- package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -78
- package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
- package/docs/v7/{api/elements.mdx → elements.mdx} +1 -54
- package/docs/v7/enterprise.mdx +116 -0
- package/docs/v7/examples.mdx +5 -0
- package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
- package/docs/v7/{api/find.mdx → find.mdx} +17 -21
- package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
- package/docs/v7/generating-tests.mdx +36 -0
- package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
- package/docs/v7/locating-elements.mdx +71 -0
- package/docs/v7/making-assertions.mdx +32 -0
- package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
- package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
- package/docs/v7/performing-actions.mdx +51 -0
- package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
- package/docs/v7/quickstart.mdx +162 -0
- package/docs/v7/reusable-code.mdx +240 -0
- package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
- package/docs/v7/running-tests.mdx +181 -0
- package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
- package/docs/v7/secrets.mdx +115 -0
- package/docs/v7/self-hosted.mdx +66 -0
- package/docs/v7/{api/type.mdx → type.mdx} +3 -3
- package/docs/v7/variables.mdx +111 -0
- package/docs/v7/waiting-for-elements.mdx +66 -0
- package/docs/v7/what-is-testdriver.mdx +54 -0
- package/lib/vitest/hooks.mjs +80 -68
- package/package.json +1 -1
- package/sdk.d.ts +22 -9
- package/sdk.js +177 -44
- package/test/manual/reconnect-provision.test.mjs +49 -0
- package/test/manual/reconnect-signin.test.mjs +41 -0
- package/test/testdriver/ai.test.mjs +30 -0
- package/test/testdriver/setup/testHelpers.mjs +0 -1
- package/test/testdriver/windows-installer.test.mjs +61 -0
- package/tests/table-sort-enrollments.test.mjs +72 -0
- package/tests/table-sort-experiment.test.mjs +42 -0
- package/tests/table-sort-setup.test.mjs +59 -0
- package/vitest.config.mjs +1 -0
- package/docs/v7/api/assertions.mdx +0 -403
- package/docs/v7/api/sandbox.mdx +0 -404
- package/docs/v7/features/ai-native.mdx +0 -413
- package/docs/v7/features/application-logs.mdx +0 -353
- package/docs/v7/features/browser-logs.mdx +0 -414
- package/docs/v7/features/cache-management.mdx +0 -402
- package/docs/v7/features/continuous-testing.mdx +0 -346
- package/docs/v7/features/data-driven-testing.mdx +0 -441
- package/docs/v7/features/easy-to-write.mdx +0 -280
- package/docs/v7/features/enterprise.mdx +0 -656
- package/docs/v7/features/fast.mdx +0 -406
- package/docs/v7/features/managed-sandboxes.mdx +0 -384
- package/docs/v7/features/network-monitoring.mdx +0 -568
- package/docs/v7/features/parallel-execution.mdx +0 -381
- package/docs/v7/features/powerful.mdx +0 -531
- package/docs/v7/features/sandbox-customization.mdx +0 -229
- package/docs/v7/features/stable.mdx +0 -473
- package/docs/v7/features/system-performance.mdx +0 -616
- package/docs/v7/features/test-analytics.mdx +0 -373
- package/docs/v7/features/test-cases.mdx +0 -393
- package/docs/v7/features/test-replays.mdx +0 -408
- package/docs/v7/features/test-reports.mdx +0 -308
- package/docs/v7/getting-started/debugging-tests.mdx +0 -382
- package/docs/v7/getting-started/quickstart.mdx +0 -90
- package/docs/v7/getting-started/running-tests.mdx +0 -173
- package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
- package/docs/v7/getting-started/writing-tests.mdx +0 -534
- package/docs/v7/overview/what-is-testdriver.mdx +0 -386
- package/docs/v7/presets/chrome-extension.mdx +0 -248
- package/docs/v7/presets/chrome.mdx +0 -300
- package/docs/v7/presets/electron.mdx +0 -460
- package/docs/v7/presets/vscode.mdx +0 -417
- package/docs/v7/presets/webapp.mdx +0 -393
- package/vitest.config.js +0 -18
- /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
- /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
- /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
- /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
- /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
- /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
- /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Intelligent Caching"
|
|
3
|
-
description: "1.7x faster test execution with intelligent caching and optimization"
|
|
4
|
-
icon: "bolt"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
Speed matters when you're running hundreds or thousands of tests. TestDriver is engineered for performance with intelligent caching that delivers up to **1.7x faster** test execution by skipping redundant AI vision analysis.
|
|
8
|
-
|
|
9
|
-
## Test Caching Performance
|
|
10
|
-
|
|
11
|
-
Selector caching dramatically reduces test execution time by skipping redundant AI vision analysis:
|
|
12
|
-
|
|
13
|
-
```mermaid
|
|
14
|
-
%%{init: {'theme':'base', 'themeVariables': {'xyChart': {'backgroundColor': 'transparent', 'titleColor': '#ffffff', 'xAxisLabelColor': '#ffffff', 'xAxisTitleColor': '#ffffff', 'xAxisTickColor': '#ffffff', 'xAxisLineColor': '#ffffff', 'yAxisLabelColor': '#ffffff', 'yAxisTitleColor': '#ffffff', 'yAxisTickColor': '#ffffff', 'yAxisLineColor': '#ffffff', 'plotColorPalette': '#b3d334, #b3d334'}}}}%%
|
|
15
|
-
xychart-beta
|
|
16
|
-
title "Test Execution Time Comparison"
|
|
17
|
-
x-axis ["First Run (No Cache)", "Cached Run"]
|
|
18
|
-
y-axis "Duration (seconds)" 0 --> 10
|
|
19
|
-
bar [8.2, 4.8]
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
// First run: builds cache
|
|
24
|
-
await testdriver.find('submit button');
|
|
25
|
-
|
|
26
|
-
// Second run: exact match
|
|
27
|
-
await testdriver.find('submit button');
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Performance Improvement: 1.7x faster** – The more you run your tests, the faster they get. Cache hits are nearly instant, turning slow AI analysis into millisecond lookups.
|
|
31
|
-
|
|
32
|
-
- **First run:** 45.2s with 12 AI vision calls
|
|
33
|
-
- **Cached run:** 26.6s with 11/12 cache hits
|
|
34
|
-
|
|
35
|
-
## Intelligent Cache Strategy
|
|
36
|
-
|
|
37
|
-
TestDriver uses a sophisticated three-tier matching system to maximize cache hits while maintaining accuracy:
|
|
38
|
-
|
|
39
|
-
<Steps>
|
|
40
|
-
<Step title="Exact Hash Match (Fastest)">
|
|
41
|
-
Perceptual hash comparison for identical screenshots.
|
|
42
|
-
|
|
43
|
-
- **Speed:** Instant (< 1ms)
|
|
44
|
-
- **Accuracy:** 100%
|
|
45
|
-
- **Use case:** Repeat test runs
|
|
46
|
-
|
|
47
|
-
</Step>
|
|
48
|
-
|
|
49
|
-
<Step title="Pixel Diff Match (Fast)">
|
|
50
|
-
Pixel-by-pixel comparison for similar screenshots.
|
|
51
|
-
|
|
52
|
-
- **Speed:** Very fast (< 50ms)
|
|
53
|
-
- **Accuracy:** 95%+ similarity threshold
|
|
54
|
-
- **Use case:** Minor UI changes (hover states, animations)
|
|
55
|
-
</Step>
|
|
56
|
-
|
|
57
|
-
<Step title="Template Match (Fallback)">
|
|
58
|
-
Edge detection and template matching for structural similarity.
|
|
59
|
-
|
|
60
|
-
- **Speed:** Fast (< 200ms)
|
|
61
|
-
- **Accuracy:** 75%+ confidence
|
|
62
|
-
- **Use case:** Layout changes, responsive design
|
|
63
|
-
</Step>
|
|
64
|
-
</Steps>
|
|
65
|
-
|
|
66
|
-
## Automatic Caching
|
|
67
|
-
|
|
68
|
-
Caching is enabled automatically with zero configuration:
|
|
69
|
-
|
|
70
|
-
```javascript
|
|
71
|
-
import { test } from 'vitest';
|
|
72
|
-
import { chrome } from 'testdriverai/presets';
|
|
73
|
-
|
|
74
|
-
test('auto-cached test', async (context) => {
|
|
75
|
-
const { testdriver } = await chrome(context, {
|
|
76
|
-
url: 'https://example.com'
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// First call: AI analyzes screen, saves to cache
|
|
80
|
-
await testdriver.find('More information link'); // 2.1s
|
|
81
|
-
|
|
82
|
-
// Second call: cache hit, instant response
|
|
83
|
-
await testdriver.find('More information link'); // 12ms ⚡
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
<Tip>
|
|
88
|
-
**File-Based Cache Keys:** TestDriver automatically generates cache keys from a hash of the test file calling the TestDriver methods. This means each test file has its own isolated cache namespace, preventing cache pollution between different tests while enabling fast lookups within the same test file.
|
|
89
|
-
</Tip>
|
|
90
|
-
|
|
91
|
-
### How Cache Keys Work
|
|
92
|
-
|
|
93
|
-
The cache key is computed from:
|
|
94
|
-
- **File hash**: SHA-256 hash of the test file contents
|
|
95
|
-
- **Selector prompt**: The exact text description passed to `find()`
|
|
96
|
-
- **Screenshot context**: Perceptual hash of the current screen state
|
|
97
|
-
- **Platform**: Operating system and browser version
|
|
98
|
-
|
|
99
|
-
When you modify your test file, the hash changes automatically, invalidating stale cache entries and ensuring fresh AI analysis with your updated test logic.
|
|
100
|
-
|
|
101
|
-
## Cache Hit Monitoring
|
|
102
|
-
|
|
103
|
-
Track cache performance in real-time:
|
|
104
|
-
|
|
105
|
-
```javascript
|
|
106
|
-
test('monitor cache performance', async (context) => {
|
|
107
|
-
const { testdriver } = await chrome(context, { url });
|
|
108
|
-
|
|
109
|
-
const element = await testdriver.find('submit button');
|
|
110
|
-
|
|
111
|
-
if (element.cacheHit) {
|
|
112
|
-
console.log('✅ Cache hit - instant response');
|
|
113
|
-
console.log('Strategy:', element.cacheStrategy); // 'exact', 'pixeldiff', or 'template'
|
|
114
|
-
console.log('Similarity:', `${(element.similarity * 100).toFixed(1)}%`);
|
|
115
|
-
console.log('Cache age:', element.cacheCreatedAt);
|
|
116
|
-
} else {
|
|
117
|
-
console.log('⏱️ Cache miss - AI analysis performed');
|
|
118
|
-
console.log('New cache entry created');
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Example output:
|
|
124
|
-
```
|
|
125
|
-
✅ Cache hit - instant response
|
|
126
|
-
Strategy: pixeldiff
|
|
127
|
-
Similarity: 97.3%
|
|
128
|
-
Cache age: 2024-12-02T10:15:30Z
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Configurable Thresholds
|
|
132
|
-
|
|
133
|
-
Fine-tune cache behavior for your application:
|
|
134
|
-
|
|
135
|
-
<Tabs>
|
|
136
|
-
<Tab title="Strict (Default)">
|
|
137
|
-
```javascript
|
|
138
|
-
// Default: 95% similarity required
|
|
139
|
-
await testdriver.find('submit button');
|
|
140
|
-
|
|
141
|
-
// Explicit strict threshold
|
|
142
|
-
await testdriver.find('submit button', {
|
|
143
|
-
cacheThreshold: 0.01 // 99% similarity
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**Best for:**
|
|
148
|
-
- Static content
|
|
149
|
-
- Stable UI elements
|
|
150
|
-
- Critical interactions
|
|
151
|
-
</Tab>
|
|
152
|
-
|
|
153
|
-
<Tab title="Lenient">
|
|
154
|
-
```javascript
|
|
155
|
-
// Allow more variance
|
|
156
|
-
await testdriver.find('dynamic content', {
|
|
157
|
-
cacheThreshold: 0.10 // 90% similarity
|
|
158
|
-
});
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Best for:**
|
|
162
|
-
- Dynamic content (timestamps, user data)
|
|
163
|
-
- Animated elements
|
|
164
|
-
- Responsive layouts
|
|
165
|
-
- A/B testing scenarios
|
|
166
|
-
</Tab>
|
|
167
|
-
|
|
168
|
-
<Tab title="Bypass Cache">
|
|
169
|
-
```javascript
|
|
170
|
-
// Force fresh AI analysis
|
|
171
|
-
await testdriver.find('always fresh element', {
|
|
172
|
-
cacheThreshold: -1 // Disable cache
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**Best for:**
|
|
177
|
-
- Highly dynamic content
|
|
178
|
-
- Real-time data
|
|
179
|
-
- First-time debugging
|
|
180
|
-
</Tab>
|
|
181
|
-
</Tabs>
|
|
182
|
-
|
|
183
|
-
## Cache Persistence
|
|
184
|
-
|
|
185
|
-
Cache entries are stored server-side with intelligent expiration:
|
|
186
|
-
|
|
187
|
-
| Property | Value |
|
|
188
|
-
|----------|-------|
|
|
189
|
-
| **Location** | Server (MongoDB + S3) |
|
|
190
|
-
| **Persistence** | 7 days rolling window |
|
|
191
|
-
| **Scope** | Per-team, per-test-file |
|
|
192
|
-
| **Matching** | Screenshot similarity + prompt + OS |
|
|
193
|
-
| **Invalidation** | Automatic on file changes |
|
|
194
|
-
|
|
195
|
-
The cache automatically invalidates when your test code changes, ensuring accuracy while maximizing performance.
|
|
196
|
-
|
|
197
|
-
## Cache Analytics
|
|
198
|
-
|
|
199
|
-
View cache performance in the TestDriver console:
|
|
200
|
-
|
|
201
|
-
<Steps>
|
|
202
|
-
<Step title="Access Console">
|
|
203
|
-
Visit [console.testdriver.ai](https://console.testdriver.ai)
|
|
204
|
-
</Step>
|
|
205
|
-
|
|
206
|
-
<Step title="View Cache Metrics">
|
|
207
|
-
See detailed cache statistics:
|
|
208
|
-
- Cache hit rate per test
|
|
209
|
-
- Most frequently cached selectors
|
|
210
|
-
- Cache age distribution
|
|
211
|
-
- Cost savings from caching
|
|
212
|
-
</Step>
|
|
213
|
-
|
|
214
|
-
<Step title="Manage Cache">
|
|
215
|
-
Delete stale entries or clear cache for specific tests.
|
|
216
|
-
</Step>
|
|
217
|
-
</Steps>
|
|
218
|
-
|
|
219
|
-
## Performance Best Practices
|
|
220
|
-
|
|
221
|
-
<AccordionGroup>
|
|
222
|
-
<Accordion title="1. Use Consistent Prompts">
|
|
223
|
-
```javascript
|
|
224
|
-
// ✅ Good - consistent wording
|
|
225
|
-
await testdriver.find('submit button');
|
|
226
|
-
await testdriver.find('submit button'); // Cache hit
|
|
227
|
-
|
|
228
|
-
// ❌ Bad - different wording
|
|
229
|
-
await testdriver.find('submit button');
|
|
230
|
-
await testdriver.find('the submit button'); // Cache miss
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Cache matching is prompt-specific. Use the exact same description for maximum cache hits.
|
|
234
|
-
</Accordion>
|
|
235
|
-
|
|
236
|
-
<Accordion title="2. Choose Appropriate Thresholds">
|
|
237
|
-
```javascript
|
|
238
|
-
// Stable elements: strict threshold
|
|
239
|
-
await testdriver.find('navigation logo', {
|
|
240
|
-
cacheThreshold: 0.01
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// Dynamic elements: lenient threshold
|
|
244
|
-
await testdriver.find('live feed item', {
|
|
245
|
-
cacheThreshold: 0.10
|
|
246
|
-
});
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
Match your threshold to element stability.
|
|
250
|
-
</Accordion>
|
|
251
|
-
|
|
252
|
-
<Accordion title="3. Leverage Automatic Cache Keys">
|
|
253
|
-
```javascript
|
|
254
|
-
// ✅ Recommended - per-file automatic caching
|
|
255
|
-
await testdriver.find('button');
|
|
256
|
-
|
|
257
|
-
// ⚠️ Advanced - custom cache key for shared cache
|
|
258
|
-
await testdriver.find('button', {
|
|
259
|
-
cacheKey: 'global-buttons'
|
|
260
|
-
});
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
Automatic file-based cache keys prevent cross-test issues while enabling caching.
|
|
264
|
-
</Accordion>
|
|
265
|
-
|
|
266
|
-
<Accordion title="4. Use Custom Cache Keys with Variables">
|
|
267
|
-
```javascript
|
|
268
|
-
// ❌ Without cache key - creates new cache for each variable value
|
|
269
|
-
const email = 'user@example.com';
|
|
270
|
-
await testdriver.find(`input for ${email}`); // Cache miss every time
|
|
271
|
-
|
|
272
|
-
// ✅ With cache key - reuses cache regardless of variable
|
|
273
|
-
const email = 'user@example.com';
|
|
274
|
-
await testdriver.find(`input for ${email}`, {
|
|
275
|
-
cacheKey: 'email-input'
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// Also useful for dynamic IDs, names, or other changing data
|
|
279
|
-
const orderId = generateOrderId();
|
|
280
|
-
await testdriver.find(`order ${orderId} status`, {
|
|
281
|
-
cacheKey: 'order-status' // Same cache for all orders
|
|
282
|
-
});
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
Custom cache keys prevent cache pollution when using variables in prompts, dramatically improving cache hit rates.
|
|
286
|
-
</Accordion>
|
|
287
|
-
|
|
288
|
-
<Accordion title="5. Monitor Cache Hit Rates">
|
|
289
|
-
```javascript
|
|
290
|
-
test('track cache performance', async (context) => {
|
|
291
|
-
const { testdriver } = await chrome(context, { url });
|
|
292
|
-
|
|
293
|
-
let cacheHits = 0;
|
|
294
|
-
let cacheMisses = 0;
|
|
295
|
-
|
|
296
|
-
const selectors = ['button 1', 'button 2', 'button 3'];
|
|
297
|
-
|
|
298
|
-
for (const selector of selectors) {
|
|
299
|
-
const element = await testdriver.find(selector);
|
|
300
|
-
if (element.cacheHit) cacheHits++;
|
|
301
|
-
else cacheMisses++;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
console.log(`Cache hit rate: ${(cacheHits / selectors.length * 100).toFixed(0)}%`);
|
|
305
|
-
});
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Track your cache hit rates to optimize threshold settings.
|
|
309
|
-
</Accordion>
|
|
310
|
-
</AccordionGroup>
|
|
311
|
-
|
|
312
|
-
## Real-World Performance
|
|
313
|
-
|
|
314
|
-
Here's a real test suite performance comparison:
|
|
315
|
-
|
|
316
|
-
<CodeGroup>
|
|
317
|
-
```bash No Caching
|
|
318
|
-
$ npx vitest run
|
|
319
|
-
|
|
320
|
-
✓ test/login.test.js (3 tests) 87.4s
|
|
321
|
-
✓ test/checkout.test.js (5 tests) 142.6s
|
|
322
|
-
✓ test/profile.test.js (4 tests) 98.2s
|
|
323
|
-
|
|
324
|
-
Test Files: 3 passed (3)
|
|
325
|
-
Tests: 12 passed (12)
|
|
326
|
-
Duration: 328.2s
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
```bash With Caching
|
|
330
|
-
$ npx vitest run
|
|
331
|
-
|
|
332
|
-
✓ test/login.test.js (3 tests) 31.2s [cache: 92%]
|
|
333
|
-
✓ test/checkout.test.js (5 tests) 58.7s [cache: 87%]
|
|
334
|
-
✓ test/profile.test.js (4 tests) 35.1s [cache: 94%]
|
|
335
|
-
|
|
336
|
-
Test Files: 3 passed (3)
|
|
337
|
-
Tests: 12 passed (12)
|
|
338
|
-
Duration: 125.0s (2.6x faster ⚡)
|
|
339
|
-
```
|
|
340
|
-
</CodeGroup>
|
|
341
|
-
|
|
342
|
-
<Check>
|
|
343
|
-
**Performance improvement: 2.6x faster** with an average 91% cache hit rate across all tests.
|
|
344
|
-
</Check>
|
|
345
|
-
|
|
346
|
-
## Advanced: Custom Cache Configuration
|
|
347
|
-
|
|
348
|
-
For advanced use cases, configure caching globally:
|
|
349
|
-
|
|
350
|
-
```javascript
|
|
351
|
-
import { TestDriver } from 'testdriverai';
|
|
352
|
-
|
|
353
|
-
const testdriver = new TestDriver({
|
|
354
|
-
apiKey: process.env.TD_API_KEY,
|
|
355
|
-
cacheKey: 'my-test-suite',
|
|
356
|
-
cacheDefaults: {
|
|
357
|
-
threshold: 0.05, // 95% similarity
|
|
358
|
-
enabled: true,
|
|
359
|
-
ttl: 604800, // 7 days (in seconds)
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
## Learn More
|
|
365
|
-
|
|
366
|
-
<CardGroup cols={2}>
|
|
367
|
-
<Card
|
|
368
|
-
title="Parallel Execution"
|
|
369
|
-
icon="layer-group"
|
|
370
|
-
href="/v7/features/parallel-execution"
|
|
371
|
-
>
|
|
372
|
-
Run tests concurrently for maximum speed
|
|
373
|
-
</Card>
|
|
374
|
-
|
|
375
|
-
<Card
|
|
376
|
-
title="Selector Caching Guide"
|
|
377
|
-
icon="crosshairs"
|
|
378
|
-
href="/v7/guides/caching-selectors"
|
|
379
|
-
>
|
|
380
|
-
Deep dive into caching strategies
|
|
381
|
-
</Card>
|
|
382
|
-
|
|
383
|
-
<Card
|
|
384
|
-
title="AI Prompt Caching"
|
|
385
|
-
icon="brain"
|
|
386
|
-
href="/v7/guides/caching-ai"
|
|
387
|
-
>
|
|
388
|
-
Cache AI-generated test code
|
|
389
|
-
</Card>
|
|
390
|
-
|
|
391
|
-
<Card
|
|
392
|
-
title="Performance Guide"
|
|
393
|
-
icon="gauge-high"
|
|
394
|
-
href="/v7/guides/performance"
|
|
395
|
-
>
|
|
396
|
-
Optimize test suite performance
|
|
397
|
-
</Card>
|
|
398
|
-
|
|
399
|
-
<Card
|
|
400
|
-
title="Console Dashboard"
|
|
401
|
-
icon="chart-simple"
|
|
402
|
-
href="https://console.testdriver.ai"
|
|
403
|
-
>
|
|
404
|
-
View cache analytics
|
|
405
|
-
</Card>
|
|
406
|
-
</CardGroup>
|