Commit a663956
committed
feat: add timeout mechanism to WebSocket mock waitForConnection method
Prevents test hangs by adding a 5-second timeout to the waitForConnection
method in WebSocketScenario. If a WebSocket connection doesn't open within
the timeout period, the promise rejects with a descriptive error message.
Changes:
- Added timeout timer that rejects after 5 seconds
- Proper cleanup of both timeout and polling interval on success
- Switched from recursive setTimeout to setInterval for cleaner polling
- Enhanced error message for timeout scenarios
- Maintains backward compatibility with existing tests
This ensures tests fail gracefully instead of hanging indefinitely when
WebSocket connections fail to establish.1 parent 9350dbf commit a663956
1 file changed
Lines changed: 29 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 334 | + | |
343 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
344 | 363 | | |
345 | 364 | | |
346 | 365 | | |
0 commit comments