increase log retrieval timeout

This commit is contained in:
Lukas Hass 2022-02-18 15:41:02 +01:00
parent 6db6dd7e4d
commit cf6204f0db
No known key found for this signature in database
GPG Key ID: 7C8CEF72C4039178

View File

@ -1,20 +1,26 @@
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
const POLLING_INTERVAL = 50;
/** /**
* Tries to find a given log message in the logs (for 10 seconds) * Tries to find a given log message in the logs (for 10 seconds)
*/ */
export async function assertLogMessage(page, substring): Promise<void> { export async function assertLogMessage(
page,
substring: string,
timeout: number = 10000
): Promise<void> {
let logs = []; let logs = [];
await page.on('console', async (msg) => { await page.on('console', async (msg) => {
logs.push(await msg.text()); logs.push(await msg.text());
}); });
// wait for log to appear // 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)) { if (logs.includes(substring)) {
break; break;
} }
await page.waitForTimeout(50); await page.waitForTimeout(POLLING_INTERVAL);
} }
expect(logs).toContain(substring); expect(logs).toContain(substring);