Function
eventuallyOk
(
fn: () => Promise<T> | T,
timeout = 1000,
wait = 10,
)
Source from the content-addressed store, hash-verified
| 83 | export const itIntegrates = itIntegratesBasic; |
| 84 | |
| 85 | export const eventuallyOk = async <T>( |
| 86 | fn: () => Promise<T> | T, |
| 87 | timeout = 1000, |
| 88 | wait = 10, |
| 89 | ): Promise<T> => { |
| 90 | const deadline = Date.now() + timeout; |
| 91 | while (true) { |
| 92 | try { |
| 93 | return await fn(); |
| 94 | } catch (e) { |
| 95 | if (Date.now() + wait > deadline) { |
| 96 | throw e; |
| 97 | } |
| 98 | |
| 99 | await delay(wait); |
| 100 | } |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | afterEach(async () => { |
| 105 | await del([`${forceForwardSlashes(testFixturesDir)}/**`], { |