condition-based-waiting

Replace arbitrary timeouts with condition polling in test automation.

Updated Dec 14, 2025
One-click install
npx skills add https://github.com/pproenca/dot-claude --skill condition-based-waiting-pproenca
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/pproenca/dot-claude/tree/main/plugins/super/skills/condition-based-waiting
Command: npx skills add https://github.com/pproenca/dot-claude --skill condition-based-waiting-pproenca

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests with arbitrary setTimeout or sleep calls are prone to race conditions, leading to flaky, inconsistent results that pass on some machines and fail on others.

Core Features & Use Cases

  • Condition Polling: Replaces fixed delays with intelligent polling that waits for actual state changes or events, making tests robust.
  • Reliable Async Tests: Eliminates timing guesses, making asynchronous tests consistently pass and reducing debugging time.
  • Clear Timeout Errors: Provides descriptive error messages when conditions are not met within a specified timeout, aiding diagnosis.
  • Use Case: If your integration tests are intermittently failing due to timing issues, this skill helps you refactor them to wait for specific events or conditions to be true, making them consistently pass.

Quick Start

I have a flaky test that uses 'setTimeout(..., 500)'. Use the condition-based-waiting skill to refactor it to wait for a specific event instead.

Frequently Asked Questions about condition-based-waiting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky tests caused by timing issues and race conditions?

Replace arbitrary timeouts with condition-based polling that waits for actual state changes or events. Instead of fixed delays, implement a generic waitFor utility with configurable timeout and polling intervals to detect when specific conditions are met, eliminating timing guesses and making asynchronous tests consistently pass.

What's the best way to handle async waits in test automation?

Use condition polling with specialized helpers for event-based, count-based, and predicate-based waits instead of setTimeout or sleep calls. This approach guarantees reliable, deterministic test flows by actively checking for readiness states or item counts rather than waiting arbitrarily.

How do I eliminate setTimeout delays from integration tests?

Refactor fixed delays into condition-based waiting that polls for specific events or state changes. The skill provides a generic waitFor utility plus specialized helpers to replace arbitrary timeouts, ensuring tests wait for actual conditions to be true before proceeding.

Can condition-based waiting work with CI pipelines and integration tests?

Yes, condition-based waiting applies to test automation, CI pipelines, and integration tests. It automates flaky test waiting by polling for events, readiness states, or item counts, providing clear timeout errors when conditions aren't met within the specified window.

Why do tests fail intermittently with sleep and setTimeout calls?

Fixed-delay waits create race conditions because execution speed varies across machines and environments. Condition-based polling solves this by actively checking for actual state changes, making tests robust and consistent rather than dependent on timing assumptions.

What diagnostic information does condition-based waiting provide when tests timeout?

Condition-based waiting generates descriptive error messages when conditions aren't met within a specified timeout, aiding diagnosis and reducing debugging time by clearly identifying what condition failed and when.