You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/test-helpers/waiter.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ The waiter module provides utilities for waiting on specific content to appear i
9
9
-**Composable Waiting**: Wait for any of multiple conditions or all conditions to be met
10
10
-**Flexible Timeout Handling**: Configure timeout behavior and error handling to suit your needs
11
11
-**Shell Prompt Detection**: Easily wait for shell readiness with built-in prompt detection
12
+
-**Robust Error Handling**: Improved exception handling and result reporting
13
+
-**Clean Code**: Well-formatted, linted code with proper type annotations
12
14
13
15
## Basic Concepts
14
16
@@ -52,12 +54,14 @@ Control how long to wait and what happens when a timeout occurs:
52
54
53
55
### Waiting for Shell Readiness
54
56
55
-
A common use case is waiting for a shell prompt to appear, indicating the command has completed:
57
+
A common use case is waiting for a shell prompt to appear, indicating the command has completed. The example below uses a regular expression to match common shell prompt characters (`$`, `%`, `>`, `#`):
> Note: This test is skipped in CI environments due to timing issues but works well for local development.
64
+
61
65
## Fluent API (Playwright-inspired)
62
66
63
67
For a more expressive and chainable API, you can use the fluent interface provided by the `PaneContentWaiter` class:
@@ -153,3 +157,25 @@ These methods configure the waiter and return a new waiter with the updated conf
153
157
*`elapsed_time`: The time elapsed during the wait
154
158
*`error`: The error message, if any
155
159
*`matched_pattern_index`: The index of the matched pattern (for wait_for_any_content)
160
+
161
+
## Implementation Notes
162
+
163
+
### Error Handling
164
+
165
+
The waiting functions are designed to be robust and handle timing and error conditions gracefully:
166
+
167
+
- All wait functions properly calculate elapsed time for performance tracking
168
+
- Functions handle exceptions consistently and provide clear error messages
169
+
- Proper handling of return values ensures consistent behavior whether or not raises=True
170
+
171
+
### Type Safety
172
+
173
+
The waiter module is fully type-annotated to ensure compatibility with static type checkers:
174
+
175
+
- All functions include proper type hints for parameters and return values
176
+
- The ContentMatchType enum ensures that only valid match types are used
177
+
- Combined with runtime checks, this prevents type-related errors during testing
178
+
179
+
### Example Usage in Documentation
180
+
181
+
All examples in this documentation are actual test files from the libtmux test suite. The examples are included using `literalinclude` directives, ensuring that the documentation remains synchronized with the actual code.
0 commit comments