Const
import {waitUntil} from '@augment-vir/assert';
// `result` will eventually be `'123'`
const result = await waitUntil.isString(
() => {
if (Math.random() < 0.5) {
return 123;
} else {
return '123';
}
},
{
interval: {milliseconds: 100},
timeout: {seconds: 10},
},
);
AssertionError When the assertion fails.
A group of guard methods that run the given callback multiple times until its return value matches expectations. Callback interval and timeout can be customized with WaitUntilOptions.
This can also be called as a standalone wait until function which waits until the callback's returned value is truthy.