MCPcopy Create free account
hub / github.com/TanStack/query / waitFor

Function waitFor

packages/lit-query/src/tests/testHost.ts:87–98  ·  view source on GitHub ↗
(
  assertion: () => boolean,
  timeoutMs = 2000,
)

Source from the content-addressed store, hash-verified

85}
86
87export async function waitFor(
88 assertion: () => boolean,
89 timeoutMs = 2000,
90): Promise<void> {
91 const startedAt = Date.now()
92 while (!assertion()) {
93 if (Date.now() - startedAt > timeoutMs) {
94 throw new Error(`Timed out waiting for assertion after ${timeoutMs}ms`)
95 }
96 await sleep(10)
97 }
98}
99
100function isMissingQueryClientError(error: unknown): boolean {
101 return (

Callers 1

Calls 1

sleepFunction · 0.90

Tested by

no test coverage detected