From b1b11f09e2835b19b6e344df7f2bba0c31934492 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 1 Jan 2022 11:40:31 +0900 Subject: [PATCH] add maxAttempts --- test/helpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helpers.ts b/test/helpers.ts index 930d2de94c..ceb71a1185 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -280,13 +280,13 @@ export function prettyPrintPuppeteerAssertionError(message) { } } -export async function retryAsync(fn: () => Promise): Promise { +export async function retryAsync(fn: () => Promise, maxAttempts: number = 3): Promise { let attempts = 0; - while (attempts <= 3) { + while (attempts <= maxAttempts) { try { return await fn(); } catch (err) { - if (++attempts >= 3) throw err; + if (++attempts >= maxAttempts) throw err; } } }