Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: unflake "should fail when frame detaches" (#9095)

Dmitry Gozmanb978ce33cb27
diff --git a/tests/page/page-wait-for-navigation.spec.ts b/tests/page/page-wait-for-navigation.spec.ts
index 336e2e3708..fbd34ae218 100644
--- a/tests/page/page-wait-for-navigation.spec.ts
+++ b/tests/page/page-wait-for-navigation.spec.ts
@@ -238,12 +238,10 @@ it('should fail when frame detaches', async ({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html');
const frame = page.frames()[1];
server.setRoute('/empty.html', () => {});
- let error = null;
- await Promise.all([
- frame.waitForNavigation().catch(e => error = e),
- frame.evaluate('window.location.href = "/empty.html"'),
- page.evaluate('setTimeout(() => document.querySelector("iframe").remove())'),
- ]).catch(e => error = e);
+ const [error] = await Promise.all([
+ frame.waitForNavigation().catch(e => e),
+ page.evaluate('var frame = document.querySelector("iframe"); frame.contentWindow.location.href = "/empty.html"; setTimeout(() => frame.remove())'),
+ ]);
expect(error.message).toContain('waiting for navigation until "load"');
expect(error.message).toContain('frame was detached');
});