increase log retrieval timeout
This commit is contained in:
parent
6db6dd7e4d
commit
cf6204f0db
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user