From cf6204f0dbd2cd70eddccfdbbfda5c1864eddca9 Mon Sep 17 00:00:00 2001 From: Lukas Hass Date: Fri, 18 Feb 2022 15:41:02 +0100 Subject: [PATCH] increase log retrieval timeout --- tests/tests/utils/log.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/tests/utils/log.ts b/tests/tests/utils/log.ts index c07af44f..bf0a5e69 100644 --- a/tests/tests/utils/log.ts +++ b/tests/tests/utils/log.ts @@ -1,20 +1,26 @@ import { expect } from '@playwright/test'; +const POLLING_INTERVAL = 50; + /** * Tries to find a given log message in the logs (for 10 seconds) */ -export async function assertLogMessage(page, substring): Promise { +export async function assertLogMessage( + page, + substring: string, + timeout: number = 10000 +): Promise { let logs = []; await page.on('console', async (msg) => { logs.push(await msg.text()); }); // wait for log to appear - for (let i = 0; i < 10; i++) { + for (let i = 0; i < timeout / POLLING_INTERVAL; i++) { if (logs.includes(substring)) { break; } - await page.waitForTimeout(50); + await page.waitForTimeout(POLLING_INTERVAL); } expect(logs).toContain(substring);