From f14f69624f3793c84537a546b67969cae67ceff9 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 3 Oct 2022 12:28:19 -0700 Subject: [PATCH] test: unflake network idle test (#17784) Too slow on Firefox to fit 500ms network idle timeout. --- tests/page/page-network-idle.spec.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/page/page-network-idle.spec.ts b/tests/page/page-network-idle.spec.ts index 7d7a90f9d1..d570ccbb8b 100644 --- a/tests/page/page-network-idle.spec.ts +++ b/tests/page/page-network-idle.spec.ts @@ -156,17 +156,23 @@ it('should wait for networkidle from the popup', async ({ page, server }) => { } }); -it('should wait for networkidle when iframe attaches and detaches', async ({ page }) => { - await page.setContent(` +it('should wait for networkidle when iframe attaches and detaches', async ({ page, server }) => { + server.setRoute('/empty.html', () => {}); + let done = false; + const promise = page.setContent(` - `, { waitUntil: 'networkidle' }); - expect(await page.$('iframe')).toBe(null); + `, { waitUntil: 'networkidle' }).then(() => done = true); + await page.waitForTimeout(600); + expect(done).toBe(false); + await page.evaluate(() => { + document.querySelector('iframe').remove(); + }); + await promise; + expect(done).toBe(true); });