Waits for a resolver to return a value. Continues checking until resolver does not throw an error.
resolver
The condition/resolver to be fulfilled. The resolver needs to throw an error to communicate that the value is not yet ready.
Optional
A promise that transports the value of the resolver.
An error if the condition is not fulfilled within the specified timeout.
import { waitFor } from "test-utils/waitFor";const result = await waitFor(() => { const value = getValue(); if (value === undefined) { throw new Error("Value not ready"); } return value;});assert.equal(result, "myValue"); Copy
import { waitFor } from "test-utils/waitFor";const result = await waitFor(() => { const value = getValue(); if (value === undefined) { throw new Error("Value not ready"); } return value;});assert.equal(result, "myValue");
Waits for a resolver to return a value. Continues checking until
resolver
does not throw an error.