diff --git a/src/test/matchers/toBeTruthy.ts b/src/test/matchers/toBeTruthy.ts index a8b951ae26..1927ea67a1 100644 --- a/src/test/matchers/toBeTruthy.ts +++ b/src/test/matchers/toBeTruthy.ts @@ -48,7 +48,7 @@ export async function toBeTruthy( received = await query(remainingTime); pass = !!received; return pass === !matcherOptions.isNot; - }, options.timeout, 100, testInfo._testFinished); + }, options.timeout, testInfo._testFinished); const message = () => { return matcherHint(matcherName, undefined, '', matcherOptions); diff --git a/src/test/matchers/toEqual.ts b/src/test/matchers/toEqual.ts index 02731e5614..0c337af63a 100644 --- a/src/test/matchers/toEqual.ts +++ b/src/test/matchers/toEqual.ts @@ -64,7 +64,7 @@ export async function toEqual( received = await query(remainingTime); pass = equals(received, expected, [iterableEquality]); return pass === !matcherOptions.isNot; - }, options.timeout, 100, testInfo._testFinished); + }, options.timeout, testInfo._testFinished); const message = pass ? () => diff --git a/src/test/matchers/toMatchText.ts b/src/test/matchers/toMatchText.ts index f4acd68255..a060e5559a 100644 --- a/src/test/matchers/toMatchText.ts +++ b/src/test/matchers/toMatchText.ts @@ -80,7 +80,7 @@ export async function toMatchText( pass = expected.test(received); return pass === !matcherOptions.isNot; - }, options.timeout, 100, testInfo._testFinished); + }, options.timeout, testInfo._testFinished); const stringSubstring = options.matchSubstring ? 'substring' : 'string'; const message = pass diff --git a/src/test/util.ts b/src/test/util.ts index 4b83064cb6..a941065a46 100644 --- a/src/test/util.ts +++ b/src/test/util.ts @@ -71,7 +71,7 @@ export async function raceAgainstDeadline(promise: Promise, deadline: numb return (new DeadlineRunner(promise, deadline)).result; } -export async function pollUntilDeadline(state: ReturnType, func: (remainingTime: number) => Promise, pollTime: number | undefined, pollInterval: number, deadlinePromise: Promise): Promise { +export async function pollUntilDeadline(state: ReturnType, func: (remainingTime: number) => Promise, pollTime: number | undefined, deadlinePromise: Promise): Promise { const playwrightActionTimeout = (state as any).playwrightActionTimeout; pollTime = pollTime === 0 ? 0 : pollTime || playwrightActionTimeout; const deadline = pollTime ? monotonicTime() + pollTime : 0; @@ -82,6 +82,8 @@ export async function pollUntilDeadline(state: ReturnType, f return true; }); + const pollIntervals = [100, 250, 500]; + let attempts = 0; while (!aborted) { const remainingTime = deadline ? deadline - monotonicTime() : 1000 * 3600 * 24; if (remainingTime <= 0) @@ -102,7 +104,7 @@ export async function pollUntilDeadline(state: ReturnType, f } let timer: NodeJS.Timer; - const timeoutPromise = new Promise(f => timer = setTimeout(f, pollInterval)); + const timeoutPromise = new Promise(f => timer = setTimeout(f, pollIntervals[attempts++] || 1000)); await Promise.race([abortedPromise, timeoutPromise]); clearTimeout(timer!); }