What problem does it solves?
Tests with arbitrary setTimeout or sleep calls are prone to flakiness, failing inconsistently due to race conditions or timing dependencies, leading to unreliable CI/CD and wasted debugging time.
Core Features & Use Cases
- Condition Polling: Replaces arbitrary timeouts with a generic
waitFor function that polls for actual state changes or events.
- Flaky Test Elimination: Makes async tests robust and reliable by waiting for the precise condition, not a guessed duration.
- Clear Error Reporting: Provides descriptive timeout errors if the condition is not met within a specified duration.
- Use Case: You have a test that intermittently fails because an async operation isn't complete before assertions run. Use this Skill to replace the unreliable
setTimeout with a waitFor function that polls for the actual state change, making your test robust and reliable.
Quick Start
Use the condition-based-waiting skill to refactor a flaky test that uses setTimeout(..., 50) by replacing it with a waitFor call that checks for a specific event.