API reference@evolu/commonAssert › assertConditionAfterMicrotasks

function assertConditionAfterMicrotasks(
  condition: () => boolean,
  expectedMicrotaskCount: number,
): Promise<void>;

Defined in: packages/common/src/Assert.ts:255

Asserts that a condition becomes true after exactly the specified number of microtasks.

Use this in tests that intentionally specify async scheduling behavior. Application code must not depend on exact microtask counts. Maintainers should review count changes because they indicate that an async pipeline changed.

Example

import { assertConditionAfterMicrotasks } from "@evolu/common";

let ready = false;
queueMicrotask(() => {
  ready = true;
});

await assertConditionAfterMicrotasks(() => ready, 1);