@testdriverai/mcp 7.9.150-test → 7.9.152-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 (39) hide show
  1. package/ai/skills/testdriver-caching/SKILL.md +13 -6
  2. package/ai/skills/testdriver-ci-cd/SKILL.md +20 -34
  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/ci-cd.mdx +20 -34
  18. package/docs/v7/client.mdx +1 -1
  19. package/docs/v7/copilot/auto-healing.mdx +167 -18
  20. package/docs/v7/copilot/running-tests.mdx +915 -54
  21. package/docs/v7/debugging-with-screenshots.mdx +17 -7
  22. package/docs/v7/generating-tests.mdx +166 -10
  23. package/docs/v7/making-assertions.mdx +81 -4
  24. package/docs/v7/performing-actions.mdx +100 -4
  25. package/docs/v7/quickstart.mdx +299 -21
  26. package/docs/v7/wait.mdx +1 -1
  27. package/package.json +3 -3
  28. package/docs/v7/ai/agent.mdx +0 -72
  29. package/docs/v7/ai/mcp.mdx +0 -228
  30. package/docs/v7/ai/skills.mdx +0 -73
  31. package/docs/v7/ai.mdx +0 -205
  32. package/docs/v7/copilot/creating-tests.mdx +0 -156
  33. package/docs/v7/copilot/github.mdx +0 -143
  34. package/docs/v7/copilot/setup.mdx +0 -143
  35. package/docs/v7/device-config.mdx +0 -317
  36. package/docs/v7/locating-elements.mdx +0 -71
  37. package/docs/v7/machine-setup.mdx +0 -331
  38. package/docs/v7/running-tests.mdx +0 -185
  39. package/docs/v7/waiting-for-elements.mdx +0 -90
@@ -1,331 +0,0 @@
1
- ---
2
- title: "Machine Setup"
3
- description: "Configure Linux and Windows sandboxes, persist machines between runs, and install custom software"
4
- icon: "desktop"
5
- ---
6
-
7
- TestDriver provisions a fresh cloud VM for every test by default. This guide covers how to configure Linux and Windows machines, reduce startup time by keeping machines alive between runs, use provision scripts for repeatable setup, and install custom software on the fly.
8
-
9
- ---
10
-
11
- ## Linux Machines
12
-
13
- Linux is the default operating system. No extra configuration is required.
14
-
15
- ```javascript
16
- import { describe, expect, it } from "vitest";
17
- import { TestDriver } from "testdriverai/vitest/hooks";
18
-
19
- describe("My Test", () => {
20
- it("runs on Linux", async (context) => {
21
- const testdriver = TestDriver(context);
22
-
23
- await testdriver.provision.chrome({ url: "https://example.com" });
24
-
25
- const result = await testdriver.assert("the page loaded successfully");
26
- expect(result).toBeTruthy();
27
- });
28
- });
29
- ```
30
-
31
- ### Common Linux Options
32
-
33
- | Option | Type | Default | Description |
34
- |--------|------|---------|-------------|
35
- | `os` | string | `"linux"` | Operating system |
36
- | `resolution` | string | `"1366x768"` | Screen resolution (Enterprise only) |
37
- | `e2bTemplateId` | string | — | Custom E2B template ID (see [Self-Hosted](/v7/self-hosted)) |
38
- | `keepAlive` | number | `60000` | Ms to keep VM alive after disconnect |
39
- | `reconnect` | boolean | `false` | Reconnect to last used sandbox |
40
-
41
- ```javascript
42
- const testdriver = TestDriver(context, {
43
- os: "linux",
44
- resolution: "1920x1080",
45
- keepAlive: 5 * 60 * 1000, // keep alive 5 minutes
46
- });
47
- ```
48
-
49
- ---
50
-
51
- ## Windows Machines
52
-
53
- Set `os: "windows"` to provision a Windows VM instead. Everything else works the same way.
54
-
55
- ```javascript
56
- const testdriver = TestDriver(context, {
57
- os: "windows",
58
- });
59
-
60
- await testdriver.provision.chrome({ url: "https://example.com" });
61
- ```
62
-
63
- Windows sandboxes use EC2 instances and take longer to boot than Linux (E2B) sandboxes — typically 1–3 minutes for a cold start. See [Keeping Machines Alive](#keeping-machines-alive-between-runs) below to avoid this cost on repeated runs.
64
-
65
- ### Common Windows Options
66
-
67
- | Option | Type | Default | Description |
68
- |--------|------|---------|-------------|
69
- | `os` | string | — | Set to `"windows"` |
70
- | `resolution` | string | `"1366x768"` | Screen resolution (Enterprise only) |
71
- | `sandboxAmi` | string | — | Custom AMI ID (self-hosted) |
72
- | `sandboxInstance` | string | — | EC2 instance type (self-hosted) |
73
- | `keepAlive` | number | `60000` | Ms to keep VM alive after disconnect |
74
- | `reconnect` | boolean | `false` | Reconnect to last used sandbox |
75
-
76
- ```javascript
77
- const testdriver = TestDriver(context, {
78
- os: "windows",
79
- resolution: "1920x1080",
80
- keepAlive: 10 * 60 * 1000, // keep alive 10 minutes
81
- });
82
- ```
83
-
84
- ---
85
-
86
- ## Keeping Machines Alive Between Runs
87
-
88
- Windows (and Linux) cold starts can be expensive if you're iterating quickly. Use `keepAlive` + `reconnect` to reuse the same VM across multiple test runs.
89
-
90
- ### How it works
91
-
92
- Every time the SDK successfully connects to a sandbox, it records the sandbox id in `.testdriver/last-sandbox` inside your project directory. The next test that opts in with `reconnect: true` reads that file and reattaches automatically — no manual id tracking required.
93
-
94
- Provision calls (`testdriver.provision.chrome(...)`, `vscode(...)`, etc.) are **skipped** when reconnecting, because the application is already running inside the sandbox from the previous run.
95
-
96
- <Note>
97
- `.testdriver/last-sandbox` is already covered by the default TestDriver `.gitignore`. Don't commit it.
98
- </Note>
99
-
100
- ### Step 1 — Start the machine with a long `keepAlive`
101
-
102
- ```javascript
103
- // first.test.mjs
104
- const testdriver = TestDriver(context, {
105
- os: "windows",
106
- keepAlive: 30 * 60 * 1000, // keep alive 30 minutes after this test ends
107
- });
108
-
109
- await testdriver.provision.chrome({ url: "https://example.com" });
110
- // ... your test steps
111
- ```
112
-
113
- When this test finishes, the sandbox stays running for 30 minutes instead of being terminated immediately.
114
-
115
- ### Step 2 — Reattach automatically with `reconnect: true`
116
-
117
- ```javascript
118
- // second.test.mjs
119
- const testdriver = TestDriver(context, {
120
- os: "windows",
121
- reconnect: true, // ← reads .testdriver/last-sandbox
122
- keepAlive: 30 * 60 * 1000,
123
- });
124
-
125
- // No provision call — Chrome is already open from the previous run.
126
- await testdriver.find("Sign In button").click();
127
- ```
128
-
129
- ### Step 2 (alternative) — Reattach to an explicit id
130
-
131
- If you need to pin to a specific sandbox (CI matrix, multiple chains in parallel, etc.) pass the id directly:
132
-
133
- ```javascript
134
- await testdriver.connect({ sandboxId: "sandbox-abc123" });
135
- ```
136
-
137
- When reattaching to a sandbox:
138
- - You reuse a specific running machine directly
139
- - You continue from the app state created in the earlier run
140
- - You must run within the previous test's `keepAlive` window
141
-
142
- <Tip>
143
- Use `testdriver.getLastSandboxId()` to read the recorded sandbox id (and optional metadata) for scripting purposes.
144
- </Tip>
145
-
146
- ### Chaining describe blocks within one test file
147
-
148
- A common pattern is to break a long flow into focused `describe` blocks that share one sandbox — the first block provisions and signs in, later blocks reconnect and continue:
149
-
150
- ```javascript
151
- import { describe, expect, it } from "vitest";
152
- import { TestDriver } from "testdriverai/vitest/hooks";
153
-
154
- const KEEP_ALIVE_MS = 5 * 60 * 1000;
155
-
156
- describe("step 1 — log in", () => {
157
- it("signs in and lands on the dashboard", async (context) => {
158
- const testdriver = TestDriver(context, { keepAlive: KEEP_ALIVE_MS });
159
- await testdriver.provision.chrome({ url: "https://example.com/login" });
160
- await testdriver.find("username input").click();
161
- await testdriver.type("standard_user");
162
- await testdriver.pressKeys(["tab"]);
163
- await testdriver.type("secret_sauce", { secret: true });
164
- await testdriver.pressKeys(["enter"]);
165
- expect(await testdriver.assert("the dashboard is visible")).toBeTruthy();
166
- });
167
- });
168
-
169
- describe("step 2 — add to cart", () => {
170
- it("reuses the logged-in sandbox", async (context) => {
171
- const testdriver = TestDriver(context, {
172
- reconnect: true, // ← skip provisioning, reattach
173
- keepAlive: KEEP_ALIVE_MS,
174
- });
175
- await testdriver.find("Add to cart").click();
176
- await testdriver.find("cart icon").click();
177
- expect(await testdriver.assert("the cart has an item")).toBeTruthy();
178
- });
179
- });
180
-
181
- describe("step 3 — check out", () => {
182
- it("continues from the cart state", async (context) => {
183
- const testdriver = TestDriver(context, { reconnect: true, keepAlive: 30_000 });
184
- await testdriver.find("Checkout").click();
185
- expect(await testdriver.assert("the checkout form is visible")).toBeTruthy();
186
- });
187
- });
188
- ```
189
-
190
- A runnable copy of this pattern lives at [`examples/reconnect-sequential.test.mjs`](https://github.com/testdriverai/mono/blob/main/sdk/examples/reconnect-sequential.test.mjs).
191
-
192
- <Warning>
193
- Vitest runs **test files** in parallel by default. Within a single file, `describe`/`it` blocks run in source order, so reconnect chaining works as written. To chain across multiple files, run them sequentially (e.g. `vitest run --sequence.concurrent=false` or place them in a single project pool with workers set to 1).
194
- </Warning>
195
-
196
- ### How `keepAlive` works
197
-
198
- `keepAlive` is a duration in milliseconds. After the SDK disconnects, the server keeps the VM running for that long before terminating it. The default is `60000` (1 minute). Note: `keepAlive: 0` currently falls back to the default disconnect grace period rather than terminating immediately, so use a positive duration when you want to control the grace window explicitly.
199
-
200
- ```javascript
201
- const testdriver = TestDriver(context, {
202
- keepAlive: 0, // currently uses the default 1 minute grace period
203
- // keepAlive: 60000, // default — 1 minute
204
- // keepAlive: 600000, // 10 minutes
205
- // keepAlive: 3600000, // 1 hour
206
- });
207
- ```
208
-
209
- <Warning>
210
- Machines kept alive beyond your test session continue to consume credits. Always set a `keepAlive` value appropriate for your workflow.
211
- </Warning>
212
-
213
- ---
214
-
215
- ## Using Provision Scripts
216
-
217
- Provision scripts let you run arbitrary setup steps before your test starts — downloading fixtures, seeding a database, configuring environment variables, and more. Use `testdriver.exec()` to run shell or PowerShell commands directly in the sandbox.
218
-
219
- <Card
220
- title="exec() Reference"
221
- icon="terminal"
222
- href="/v7/exec"
223
- >
224
- Full reference for running shell and PowerShell commands in the sandbox.
225
- </Card>
226
-
227
- ### Linux setup script
228
-
229
- ```javascript
230
- await testdriver.provision.chrome({ url: "https://myapp.com" });
231
-
232
- // Run a setup script from your repo
233
- await testdriver.exec("sh", `
234
- curl -s https://myapp.com/api/reset-test-db -X POST
235
- echo "Test DB reset"
236
- `, 30000);
237
- ```
238
-
239
- ### Windows setup script (PowerShell)
240
-
241
- ```javascript
242
- await testdriver.provision.chrome({ url: "https://myapp.com" });
243
-
244
- await testdriver.exec("pwsh", `
245
- $env:API_URL = "https://staging.myapp.com"
246
- Write-Host "Environment configured"
247
- `, 15000);
248
- ```
249
-
250
- ### Clone a repo and run a script
251
-
252
- ```javascript
253
- await testdriver.exec("sh", `
254
- git clone https://github.com/myorg/test-fixtures.git /tmp/fixtures
255
- bash /tmp/fixtures/seed.sh
256
- `, 120000);
257
- ```
258
-
259
- ---
260
-
261
- ## Installing Custom Software
262
-
263
- You can install software at the start of a test using `exec()`. This works for any package available via `apt`, `brew`, `choco`, `winget`, npm, pip, or direct download.
264
-
265
- ### Linux — apt packages
266
-
267
- ```javascript
268
- await testdriver.exec("sh", `
269
- sudo apt-get update -qq
270
- sudo apt-get install -y ffmpeg imagemagick
271
- `, 120000);
272
- ```
273
-
274
- ### Linux — Node.js tools
275
-
276
- ```javascript
277
- await testdriver.exec("sh", "npm install -g @playwright/test", 60000);
278
- ```
279
-
280
- ### Windows — winget
281
-
282
- ```javascript
283
- await testdriver.exec("pwsh", `
284
- winget install --id=7zip.7zip -e --silent
285
- `, 120000);
286
- ```
287
-
288
- ### Windows — Chocolatey
289
-
290
- ```javascript
291
- await testdriver.exec("pwsh", `
292
- choco install googlechrome --yes --no-progress
293
- `, 180000);
294
- ```
295
-
296
- ### Download and run an installer
297
-
298
- ```javascript
299
- // Linux
300
- await testdriver.exec("sh", `
301
- curl -L https://example.com/installer.sh -o /tmp/installer.sh
302
- chmod +x /tmp/installer.sh
303
- /tmp/installer.sh --silent
304
- `, 300000);
305
-
306
- // Windows
307
- await testdriver.exec("pwsh", `
308
- Invoke-WebRequest -Uri "https://example.com/installer.exe" -OutFile "$env:TEMP\\installer.exe"
309
- Start-Process "$env:TEMP\\installer.exe" -ArgumentList "/S" -Wait
310
- `, 300000);
311
- ```
312
-
313
- <Note>
314
- Installing software at test start adds to your test duration. For software you use in every test, consider preloading it into a custom VM image via the Enterprise self-hosted plan.
315
- </Note>
316
-
317
- ---
318
-
319
- ## Want Software Pre-Installed on Every Machine?
320
-
321
- Installing packages at runtime works well for occasional or lightweight dependencies. But if you're installing the same 5-minute setup on every test run, you're wasting time and credits.
322
-
323
- With the **Self-Hosted Enterprise plan** you get access to our golden VM base image and Packer scripts, so you can bake your applications, dependencies, and configuration directly into a custom AMI. Tests spin up with everything already installed — zero setup time.
324
-
325
- <Card
326
- title="Self-Hosted Enterprise"
327
- icon="server"
328
- href="/v7/self-hosted"
329
- >
330
- Preload software, configure custom hardware, and run unlimited tests with a flat license fee. Our team assists with deployment and setup.
331
- </Card>
@@ -1,185 +0,0 @@
1
- ---
2
- title: "Running Tests"
3
- description: "Run TestDriver tests with Vitest test runner"
4
- icon: "play"
5
- ---
6
-
7
- Learn how to run TestDriver tests efficiently with Vitest's powerful test runner.
8
-
9
- ## Running Tests
10
-
11
- TestDriver works with Vitest's powerful test runner.
12
-
13
- <Info>
14
- Install Vitest globally for best results: `npm install vitest -g`
15
- </Info>
16
-
17
- ### Run All Tests
18
-
19
- ```bash
20
- vitest run
21
- ```
22
-
23
- Executes all test files in your project once and exits. Vitest automatically discovers files matching patterns like `*.test.js`, `*.test.mjs`, or `*.spec.js`.
24
-
25
- ### Run with Coverage
26
-
27
- ```bash
28
- vitest run --coverage
29
- ```
30
-
31
- Generates a code coverage report showing which lines of your source code were executed during tests. Coverage helps identify untested code paths. Results are displayed in the terminal and saved to a `coverage/` directory.
32
-
33
- <Info>
34
- Coverage requires the `@vitest/coverage-v8` package. Install it with `npm install -D @vitest/coverage-v8`.
35
- </Info>
36
-
37
- ### Run Specific Tests
38
-
39
- ```bash
40
- vitest run login.test.js
41
- ```
42
-
43
- Runs only the specified test file. Useful when debugging a single test or working on a specific feature.
44
-
45
- ```bash
46
- vitest run login.test.js checkout.test.js
47
- ```
48
-
49
- Runs multiple specific test files. List as many files as needed, separated by spaces.
50
-
51
- ### Filter Tests by Name
52
-
53
- ```bash
54
- vitest run --grep "login"
55
- ```
56
-
57
- The `--grep` flag filters tests by their name (the string passed to `it()` or `test()`). Only tests whose names match the pattern will run. Supports regex patterns for complex matching.
58
-
59
- ### Run Tests in a Folder
60
-
61
- ```bash
62
- vitest run tests/e2e/
63
- ```
64
-
65
- Runs all test files within a specific directory. Great for organizing tests by type (unit, integration, e2e) and running them separately.
66
-
67
- ## Parallel Execution
68
-
69
- TestDriver runs each test in its own cloud sandbox, enabling true parallel execution. Run your entire test suite in minutes instead of hours.
70
-
71
- ### Control Concurrency
72
-
73
- ```bash
74
- vitest run --maxConcurrency=5
75
- ```
76
-
77
- The `--maxConcurrency` flag limits how many tests run simultaneously. This should match your TestDriver license slots to avoid failures from exhausted slots.
78
-
79
- ### Thread Configuration
80
-
81
- ```bash
82
- vitest run --pool=threads --minThreads=2 --maxThreads=8
83
- ```
84
-
85
- Fine-tune thread allocation for optimal performance:
86
- - `--pool=threads` — Uses worker threads for test isolation
87
- - `--minThreads` — Minimum number of threads to keep alive (reduces startup overhead)
88
- - `--maxThreads` — Maximum threads to spawn (limits resource usage)
89
-
90
- ### License Slots
91
-
92
- Your TestDriver plan includes a set number of **license slots** that determine how many tests can run simultaneously. Each running test occupies one slot—when the test completes and the sandbox is destroyed, the slot is immediately available for the next test.
93
-
94
- <Info>
95
- View your available slots at [console.testdriver.ai](https://console.testdriver.ai). Upgrade anytime to increase parallelization.
96
- </Info>
97
-
98
- ### Configuring Concurrency
99
-
100
- Set `maxConcurrency` in your Vitest config to match your license slot limit:
101
-
102
- ```javascript vitest.config.mjs
103
- import { defineConfig } from 'vitest/config';
104
- import TestDriver from 'testdriverai/vitest';
105
-
106
- export default defineConfig({
107
- test: {
108
- testTimeout: 900000,
109
- hookTimeout: 900000,
110
- maxConcurrency: 5, // Match your license slot limit
111
- reporters: ['default', TestDriver()],
112
- setupFiles: ['testdriverai/vitest/setup'],
113
- },
114
- });
115
- ```
116
-
117
- <Warning>
118
- Setting `maxConcurrency` higher than your license slots will cause tests to fail when slots are exhausted. Always match this value to your plan's limit.
119
- </Warning>
120
-
121
- ### Why Parallelization Matters
122
-
123
- | Test Suite | Sequential (1 slot) | Parallel (5 slots) | Parallel (10 slots) |
124
- |------------|--------------------|--------------------|---------------------|
125
- | 10 tests @ 2min each | 20 min | 4 min | 2 min |
126
- | 50 tests @ 2min each | 100 min | 20 min | 10 min |
127
- | 100 tests @ 2min each | 200 min | 40 min | 20 min |
128
-
129
- <Tip>
130
- **Pro tip:** Upgrading your plan doesn't just increase speed—it enables faster CI/CD feedback loops, letting your team ship with confidence.
131
- </Tip>
132
-
133
- <Card
134
- title="View Plans & Pricing"
135
- icon="credit-card"
136
- href="/v7/hosted"
137
- >
138
- Compare plans and find the right level of parallelization for your team.
139
- </Card>
140
-
141
- ## Vitest UI
142
-
143
- Use Vitest UI for interactive debugging:
144
-
145
- ```bash
146
- vitest --ui
147
- ```
148
-
149
- The `--ui` flag launches a web-based interface for managing your test suite. Unlike `vitest run`, this starts in watch mode by default.
150
-
151
- Open http://localhost:51204 to see:
152
- - **Test file tree** — Browse and navigate your test structure
153
- - **Test status and duration** — See pass/fail states and timing at a glance
154
- - **Console output** — View logs and errors inline with each test
155
- - **Re-run individual tests** — Click to re-execute specific tests without restarting
156
- - **Filter and search** — Quickly find tests by name or status
157
-
158
- <Tip>
159
- Combine with `--open` to automatically open the UI in your browser: `vitest --ui --open`
160
- </Tip>
161
-
162
-
163
- ## Test Reports
164
-
165
- After running tests, view detailed reports and video replays at [console.testdriver.ai](https://console.testdriver.ai).
166
-
167
- Reports include:
168
- - **Video replays** - Watch exactly what happened during each test
169
- - **Screenshots** - See the state at each step
170
- - **Timing breakdown** - Identify slow operations
171
- - **Error details** - Debug failures with full context
172
-
173
- ```bash
174
- $ vitest run
175
-
176
- ✓ login.test.js (2) 18.4s
177
- ✓ user can login 12.3s
178
- ✓ shows error for invalid credentials 6.1s
179
-
180
- 📹 View reports at: https://console.testdriver.ai
181
- ```
182
-
183
- <Tip>
184
- Bookmark your team's dashboard at [console.testdriver.ai](https://console.testdriver.ai) for quick access to test history and analytics.
185
- </Tip>
@@ -1,90 +0,0 @@
1
- ---
2
- title: "Waiting for Elements"
3
- description: "Handle async operations and prevent flaky tests"
4
- icon: "clock"
5
- ---
6
-
7
- ## Waiting for Elements
8
-
9
- By default, `find()` automatically polls for up to 10 seconds, retrying every 5 seconds until the element is found. This means most elements that appear after short async operations will be found without any extra configuration.
10
-
11
- For longer operations, increase the `timeout`:
12
-
13
- ```javascript
14
- // Default behavior - polls for up to 10 seconds automatically
15
- const element = await testdriver.find('Loading complete indicator');
16
- await element.click();
17
-
18
- // Wait up to 30 seconds for slower operations
19
- const element = await testdriver.find('Loading complete indicator', { timeout: 30000 });
20
- await element.click();
21
-
22
- // Useful after actions that trigger loading states
23
- await testdriver.find('submit button').click();
24
- await testdriver.find('success message', { timeout: 15000 });
25
-
26
- // Disable polling for instant checks
27
- const toast = await testdriver.find('notification toast', { timeout: 0 });
28
- ```
29
-
30
- ## Flake Prevention
31
-
32
- TestDriver automatically waits for the screen and network to stabilize after each action using **redraw detection**. This prevents flaky tests caused by animations, loading states, or dynamic content updates.
33
-
34
- <Note>
35
- Redraw detection adds a small delay after each action but significantly reduces test flakiness.
36
- </Note>
37
-
38
- For example, when clicking a submit button that navigates to a new page:
39
-
40
- ```javascript
41
- // Click submit - TestDriver automatically waits for the new page to load
42
- await testdriver.find('submit button').click();
43
-
44
- // By the time this runs, the page has fully loaded and stabilized
45
- await testdriver.assert('dashboard is displayed');
46
- await testdriver.find('welcome message');
47
- ```
48
-
49
- Without redraw detection, you'd need manual waits or retries to handle the page transition. TestDriver handles this automatically by detecting when the screen stops changing and network requests complete.
50
-
51
- You can disable redraw detection or customize its behavior:
52
-
53
- ```javascript
54
- // Disable redraw detection for faster tests (less reliable)
55
- const testdriver = TestDriver(context, {
56
- redraw: false
57
- });
58
- ```
59
-
60
- Here is an example of customizing redraw detection:
61
-
62
- ```javascript
63
- // Fine-tune redraw detection
64
- const testdriver = TestDriver(context, {
65
- redraw: {
66
- enabled: true,
67
- diffThreshold: 0.1, // Pixel difference threshold (0-1)
68
- screenRedraw: true, // Monitor screen changes
69
- networkMonitor: true, // Wait for network idle
70
- }
71
- });
72
- ```
73
-
74
- ## Simple Delays with `wait()`
75
-
76
- For simple pauses — waiting for animations, transitions, or state changes after an action — use `wait()`:
77
-
78
- ```javascript
79
- // Wait for an animation to complete
80
- await testdriver.find('menu toggle').click();
81
- await testdriver.wait(2000);
82
-
83
- // Wait for a page transition to settle
84
- await testdriver.find('next page button').click();
85
- await testdriver.wait(1000);
86
- ```
87
-
88
- <Note>
89
- For waiting for specific **elements** to appear, prefer `find()` with a `timeout` option. Use `wait()` only for simple time-based pauses.
90
- </Note>