Function: waitFor()
waitFor<
T>(callback,options?):Promise<T>
Defined in: wait-for.ts:26
Waits for a callback to succeed.
Repeatedly calls the callback until it returns without throwing, or until the timeout is reached.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | () => T | Promise<T> | Function to execute repeatedly |
options? | WaitForOptions | Timeout and interval configuration |
Returns
Promise<T>
Promise resolving to the callback's return value
Example
import { waitFor } from "@gtkx/testing";
await waitFor(() => {
expect(counter.value).toBe(5);
}, { timeout: 2000 });