condition-based-waiting

Replace arbitrary delays with condition-based waiting in JavaScript/TypeScript test suites.

6|Updated Dec 7, 2025
One-click install
npx skills add https://github.com/timequity/plugins --skill condition-based-waiting-timequity
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/timequity/plugins/tree/main/craft-coder/condition-based-waiting
Command: npx skills add https://github.com/timequity/plugins --skill condition-based-waiting-timequity

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill replaces arbitrary timeouts with condition-based waiting to stabilize tests and reduce flakiness.

Core Features & Use Cases

  • waitFor Pattern: Wait for a condition rather than a fixed delay.
  • Best Practices: Use proper timeouts and explain the rationale.
  • React Testing Library Tips: Recommended patterns for React tests.

Quick Start

Replace setTimeout with waitFor for a given condition and provide a brief explanation of the rationale.

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?

Replace arbitrary delays with condition-based waiting to fix flaky tests. Instead of setTimeout, use a waitFor pattern that polls a condition until it's satisfied or times out, eliminating race conditions and inconsistent pass/fail behavior across CI environments.

What's the best way to wait for asynchronous operations in tests?

Implement condition-based waiting with configurable timeout and polling intervals. This approach re-evaluates your condition continuously rather than guessing a fixed delay, making tests reliable across multi-threaded and parallel environments.

Can I use condition polling with JavaScript and TypeScript test runners?

Yes. Condition-based waiting provides clear timeout errors compatible with common JavaScript and TypeScript test runners, making it straightforward to integrate into existing test suites and get meaningful failure messages.

Why do my tests pass locally but fail inconsistently in CI?

Timing dependencies and race conditions cause flakiness across environments. Condition-based waiting stabilizes tests by replacing fixed delays with actual condition checks, ensuring consistent behavior whether tests run locally or in parallel CI pipelines.

How do I apply condition polling to React tests?

Use the waitFor pattern for React components to wait until DOM elements render or state updates complete. Condition-based waiting eliminates guessing timeouts and aligns with React Testing Library best practices for reliable component testing.