condition-based-waiting

Replace arbitrary timeouts with configurable condition-based polling in test suites.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/withmartian-sandbox/ghrc-x-3126672651424eddb640ecc81321a665 --skill condition-based-waiting-withmartian-sandbox
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/withmartian-sandbox/ghrc-x-3126672651424eddb640ecc81321a665/tree/main/default/skills/condition-based-waiting
Command: npx skills add https://github.com/withmartian-sandbox/ghrc-x-3126672651424eddb640ecc81321a665 --skill condition-based-waiting-withmartian-sandbox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flaky tests that rely on arbitrary delays and guessed timeouts produce race conditions, intermittent failures in CI, and slow test suites. This Skill documents the pattern of replacing fixed sleeps with condition-based polling so tests wait for actual state changes instead of timing assumptions.

Core Features & Use Cases

  • Deterministic polling utilities: Patterns and helpers for waiting on events, state, counts, or custom predicates with configurable timeouts and clear error messages.
  • Anti-pattern elimination: Replaces setTimeout/sleep guesses to reduce flakiness, improve parallel test reliability, and shorten overall test time.
  • Real-world use: Use wait-for-event and wait-for-count semantics in async agent/tool integration tests to ensure tools start and results arrive before assertions.

Quick Start

Replace arbitrary sleeps in your test by polling the real condition until the expected event or state appears, then proceed with assertions.

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 arbitrary setTimeout delays in async test suites?▼

Condition-based polling replaces fixed sleeps by continuously checking for a specific state or event at configurable intervals. It provides polling utilities that fetch fresh data inside each poll and throw clear timeout errors, ensuring tests proceed only after actual async completion.

What is the best way to wait for asynchronous events and state changes in automated integration tests?▼

The best way to wait for asynchronous completion is using wait-for-event and wait-for-count polling semantics. These utilities check custom predicates against fresh data retrieved inside each cycle, ensuring tools start and results arrive before assertions run.

How do I replace sleep and setTimeout guesses with reliable polling for parallel test runs?▼

Replace sleep and setTimeout guesses by implementing condition-based polling utilities. These helpers wait for actual state changes instead of relying on timing assumptions, reducing intermittent CI failures and shortening overall parallel test execution time.

Can I configure custom polling intervals and maximum timeouts for async test waits?▼

Yes, condition-based polling utilities support configurable timeouts and intervals for async test waits. You can adjust these parameters to balance execution speed and reliability while receiving clear timeout errors when expected states are never reached.

Why do my automated unit tests fail intermittently in CI when using fixed delays for async operations?▼

Automated unit tests fail intermittently in CI because fixed delays create race conditions and uncertain async completion. Replacing arbitrary timeouts with condition-based polling ensures tests wait for actual state changes, eliminating timing assumptions that cause intermittent failures during parallel runs.