Skip to content

[Test] Shared awaitCondition helper to replace sleep-based waits #418

Description

@pathosDev

Rationale

The test suite contains ~684 sleep( call sites, with sleep re-declared per file as Bun.sleep (not portable to the Node/Deno smoke runs). Fixed sleeps before assertions are the primary flake source under load (see #290) and inflate suite duration. A shared polling helper that asserts on observable state instead of elapsed time removes most of them.

Scope

  • tests/util/awaitCondition(predicate, { timeoutMs, intervalMs, label }) with diagnostic timeout messages (style of tests/util/AsyncAssertions.ts), plus one portable sleep util for the few legitimate uses.
  • Convention documented: assert state, not time; prefer TestProbe.expectMessage / ManualScheduler where applicable.
  • Migrate the top flaky suites first (see [Test] Parallel-test flake catalog, stress verification and diagnosis doc #290 list), then ratchet.
  • Biome rule (via the Biome adoption issue) banning raw setTimeout/Bun.sleep in tests/ outside the util.

Documentation

  • Testing docs note (EN + DE); CONTRIBUTING testing section.

Acceptance

  • Converted top-flake suites stable across 10 consecutive full runs.
  • Lint prevents new raw-timer usages in tests/.

Relates

Improvement program M1 (foundation). #290, #325.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestinfrastructureCI / build / live-integration testspriority: highTop priority — high impact, plan nextproduction-goalBlocks or defines the path to production readiness

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions