From cb40a08ea8a5aed9504e7e6a1cfce8d6bd1fc6bc Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 1 Jan 2022 12:42:22 +0900 Subject: [PATCH] add interval --- test/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/helpers.ts b/test/helpers.ts index ceb71a1185..ad057e149b 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -280,13 +280,14 @@ export function prettyPrintPuppeteerAssertionError(message) { } } -export async function retryAsync(fn: () => Promise, maxAttempts: number = 3): Promise { +export async function retryAsync(fn: () => Promise, maxAttempts: number = 3, interval: number = 1000): Promise { let attempts = 0; while (attempts <= maxAttempts) { try { return await fn(); } catch (err) { if (++attempts >= maxAttempts) throw err; + new Promise(resolve => setTimeout(resolve, interval)); } } }