condition-based-waiting

Official

Eliminate flaky tests, wait for actual state changes.

Authorraas-dev
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill replaces unreliable arbitrary timeouts in tests with robust condition-based polling, eliminating flaky tests caused by race conditions and timing dependencies, ensuring consistent and reliable test results.

Core Features & Use Cases

  • Reliable Async Waiting: Provides a generic waitFor function to poll for a condition to become true, preventing tests from failing due to timing guesses.
  • Domain-Specific Helpers: Includes examples for waiting for specific events, event counts, or custom predicates, adaptable to various async scenarios.
  • Flaky Test Prevention: Ensures tests wait for actual state changes, not just a guessed duration, making your test suite more robust.
  • Use Case: When a test intermittently fails due to an await new Promise(r => setTimeout(r, 50)); line, use this skill to replace it with await waitFor(() => getResult() !== undefined);, making the test reliable across different environments and loads.

Quick Start

Generic polling function

async function waitFor(condition, description, timeoutMs = 5000) { const startTime = Date.now(); while (true) { const result = condition(); if (result) return result; if (Date.now() - startTime > timeoutMs) { throw new Error(Timeout waiting for ${description}); } await new Promise(r => setTimeout(r, 10)); # Poll every 10ms } }

Example: Wait for a specific event

await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT');

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: condition-based-waiting
Download link: https://github.com/raas-dev/configent/archive/main.zip#condition-based-waiting

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.