Skip to content

Lupa API Reference / @pawel-up/lupa/testing / waitUntil

Function: waitUntil()

waitUntil(condition, message?, options?): Promise<void>

Defined in: src/testing/helpers.ts:71

Polls the condition function until it returns true or the timeout is reached.

Parameters

condition

() => boolean | Promise<boolean>

Function to poll

message?

string = 'waitUntil timed out'

Message to use when throwing an error

options?

Options for waitUntil

interval?

number

timeout?

number

Returns

Promise<void>

Promise that resolves when the condition is met

Remarks

If the condition function throws an error, the error is suppressed and the polling continues until the condition returns true or the timeout expires. The interval option determines the delay between polling attempts (default is 50ms), and the timeout option determines the maximum total duration before the promise rejects with the provided message (default is 1000ms).

Example

typescript
await waitUntil(() => element.textContent === 'Hello')