Flaky CI Test & Async Timing Resolution
Fix nondeterministic test failures, unhandled async promises, and race conditions in Playwright, Jest, or Vitest.
Eliminate arbitrary sleep timers, race conditions, shared mutable state, and unhandled promises in flaky automated test suites.
Execution Workflow Procedure
Ordered steps the coding agent executes when performing this skill.
Locate Nondeterminism Triggers
Scan test files for hardcoded setTimeout / sleep calls, shared database fixtures, and missing await statements.
Implement Event-Driven Polling
Replace arbitrary time delays with auto-retrying assertions (e.g. waitFor, expect.poll, findBy).
Ensure Test Isolation
Verify that mocks, timers, and database state are cleanly wiped in beforeEach and afterEach hooks.
Agent Safety Guardrails & Anti-Hallucination Rules
- DO NOT increase sleep durations to fix flaky tests; replace them with event-driven synchronization.
- DO NOT allow tests to mutate shared global state across parallel workers.
Expected Output Format
Flakiness root cause and 100% deterministic test implementation.
Domain Verification Checks
Example Agent Invocations
Install / Configure This Skill
# Place in .cursorrules or create .cursor/rules/flaky-ci-test-async-resolution.mdc # Trigger: Whenever you perform flaky ci test & async timing resolution --- name: flaky-ci-test-async-resolution description: Eliminate nondeterministic test failures, race conditions, and arbitrary sleep waits in automated test suites. version: 1.0.0 compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity] --- # Flaky CI Test & Async Timing Resolution ## Objective Convert flaky, timing-sensitive test suites into 100% deterministic, fast-running automated tests. ## Workflow 1. **Flakiness Detection**: Find arbitrary sleep timers, unawaited promises, and shared state collisions. 2. **Event-Driven Synchronization**: Replace timers with polling assertions (`waitFor`, `expect.poll`). 3. **Fixture Isolation**: Clean mocks and test data before and after each run.
Need a quick one-time prompt for chat?
Try the Flaky Test & Async Timing Race Condition Debugger — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.
SprintKit Workflow Integrations
Complementary tools and checklists to pair with this agent workflow.
Related Agent Skills
Explore related procedural workflows in this discipline.
Comprehensive Unit Test Suite Generation (AAA Pattern)
Generate mutation-tested unit tests with Arrange-Act-Assert structure, boundary cases, and proper mock boundaries.
GitHub Actions CI/CD Pipeline & Caching Optimization
Speed up slow GitHub Actions workflows with dependency caching, matrix parallelization, and security secrets.
Next.js App Router & React Server Components Review
Inspect Next.js App Router code for RSC boundaries, data fetching waterfalls, caching, and hydration safety.