condition-based-waiting

Replace setTimeout with polling for a specified state in tests.

74|6|Updated Aug 6, 2025
One-click install
npx skills add https://github.com/mneves75/dnschat --skill condition-based-waiting-mneves75
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: condition-based-waiting
Source: https://github.com/mneves75/dnschat/tree/main/.claude/skills/condition-based-waiting
Command: npx skills add https://github.com/mneves75/dnschat --skill condition-based-waiting-mneves75

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Arbitrary timeouts (setTimeout, sleep) in tests cause flakiness, making tests unreliable and difficult to debug, especially in asynchronous operations or under varying loads.

Core Features & Use Cases

  • Condition Polling: Replaces fixed delays with intelligent polling, waiting for the actual state change or event you care about.
  • Reliable Async Testing: Ensures tests pass consistently by synchronizing with the application's actual behavior, not guessing at timing.
  • Clear Timeout Errors: Provides descriptive error messages when a condition is not met within a specified timeout.
  • Use Case: Refactor a flaky user-login.test.ts that uses setTimeout by replacing it with a waitFor function that polls for the 'loggedIn' state, making the test robust.

Quick Start

Use the condition-based-waiting skill to fix the flaky user-login.test.ts by replacing its setTimeout with a wait for the 'loggedIn' state.