condition-based-waiting

Replace arbitrary timeouts with condition polling in asynchronous tests.

1|Updated Nov 17, 2025
One-click install
npx skills add https://github.com/nimeshgurung/artifact-hub-collections --skill condition-based-waiting-nimeshgurung
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/nimeshgurung/artifact-hub-collections/tree/main/skills/raw/obra/superpowers/skills/condition-based-waiting
Command: npx skills add https://github.com/nimeshgurung/artifact-hub-collections --skill condition-based-waiting-nimeshgurung

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the common issue of flaky tests caused by arbitrary timeouts and race conditions, leading to inconsistent test results and wasted debugging time.

Core Features & Use Cases

  • Condition Polling: Replaces fixed setTimeout or sleep calls with intelligent polling for actual state changes.
  • Flaky Test Resolution: Significantly reduces or eliminates tests that pass intermittently due to timing issues.
  • Use Case: In an asynchronous web application test, instead of waiting a fixed 500ms for an element to appear, this Skill waits until the element's specific visibility condition is met, ensuring reliability.

Quick Start

Use the condition-based waiting skill to reliably wait for the 'TOOL_RESULT' event in the agent thread.

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 race conditions in asynchronous applications?

Eliminate flaky tests by replacing arbitrary timeouts with condition polling, which repeatedly checks for specific state changes until a condition is met or a timeout occurs, ensuring reliable asynchronous test execution.

What is condition polling and how does it work for asynchronous operations?

Condition polling is a technique that replaces fixed sleep calls with a generic polling function to continuously verify if a specific condition is met, resolving race conditions by waiting for actual state changes rather than arbitrary timeframes.

How do I replace fixed setTimeout calls in my testing framework?

Replace fixed setTimeout calls by implementing a generic polling function that checks a condition repeatedly until it resolves true or a timeout occurs, ensuring your testing framework waits intelligently for asynchronous visibility states.

Does condition polling work for asynchronous web application tests waiting for elements to appear?

Yes, condition polling works for asynchronous web application tests by waiting until an element's specific visibility condition is met instead of relying on a fixed delay, significantly reducing intermittently passing tests.

What is the best way to wait for state changes without introducing flaky tests?

The best way to wait for state changes is using condition polling to check for actual state updates rather than fixed delays, eliminating timing issues and ensuring consistent test results across asynchronous operations.

When should I avoid using arbitrary timeouts for race conditions?

Avoid using arbitrary timeouts for race conditions when tests pass intermittently due to timing issues, as fixed delays cannot guarantee state readiness; condition polling is required to reliably resolve asynchronous operations.