UNPKG

@ember/test-helpers

Version:
29 lines (26 loc) 1.13 kB
type Falsy = false | 0 | '' | null | undefined; export interface Options { timeout?: number; timeoutMessage?: string; } /** Wait for the provided callback to return a truthy value. This does not leverage `settled()`, and as such can be used to manage async while _not_ settled (e.g. "loading" or "pending" states). @public @param {Function} callback the callback to use for testing when waiting should stop @param {Object} [options] options used to override defaults @param {number} [options.timeout=1000] the maximum amount of time to wait @param {string} [options.timeoutMessage='waitUntil timed out'] the message to use in the reject on timeout @returns {Promise} resolves with the callback value when it returns a truthy value @example <caption> Waiting until a selected element displays text: </caption> await waitUntil(function() { return find('.my-selector').textContent.includes('something') }, { timeout: 2000 }) */ export default function waitUntil<T>(callback: () => T | void | Falsy, options?: Options): Promise<T>; export {}; //# sourceMappingURL=wait-until.d.ts.map