MCPcopy
hub / github.com/testing-library/react-hooks-testing-library / waitFor

Function waitFor

src/core/asyncUtils.ts:45–61  ·  view source on GitHub ↗
(
    callback: () => boolean | void,
    { interval = DEFAULT_INTERVAL, timeout = DEFAULT_TIMEOUT }: WaitForOptions = {}
  )

Source from the content-addressed store, hash-verified

43 }
44
45 const waitFor = async (
46 callback: () => boolean | void,
47 { interval = DEFAULT_INTERVAL, timeout = DEFAULT_TIMEOUT }: WaitForOptions = {}
48 ) => {
49 const safeCallback = () => {
50 try {
51 return callback()
52 } catch (error: unknown) {
53 return false
54 }
55 }
56
57 const result = await wait(safeCallback, { interval, timeout })
58 if (!result && timeout) {
59 throw new TimeoutError(waitFor, timeout)
60 }
61 }
62
63 const waitForValueToChange = async (
64 selector: () => unknown,

Callers 2

asyncHook.test.tsFile · 0.85

Calls 1

waitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…