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

Function waitFor

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected