What problem does it solve?
Flaky tests often rely on arbitrary setTimeout or sleep calls, guessing at timing. This creates race conditions, leading to inconsistent pass/fail results, especially under load or in CI. This skill replaces these unreliable delays with condition-based polling, ensuring tests wait for actual state changes, making them robust and reliable.
Core Features & Use Cases
- Reliable Async Testing: Replaces arbitrary timeouts with polling for specific conditions.
- Flaky Test Elimination: Prevents race conditions and inconsistent test failures.
- Generic Polling Function: Provides a reusable
waitFor utility for various conditions (events, state, counts, file existence).
- Use Case: If your UI tests are intermittently failing due to elements not being ready, use this skill to implement
waitFor functions that poll for the element's visibility or state, making your tests stable.
Quick Start
Use the condition-based-waiting skill to refactor the 'user-login.test.ts' file, replacing setTimeout calls with condition-based waits for UI elements.