Skip to content

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

test: fix flaky page event test

Pavel Feldman20e2bac857d6
diff --git a/test/launcher.spec.js b/test/launcher.spec.js
index 5b604d5f86..b097b427f3 100644
--- a/test/launcher.spec.js
+++ b/test/launcher.spec.js
@@ -177,12 +177,12 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
const remote = await playwright.connect({ wsEndpoint: browserServer.wsEndpoint() });
const context = await remote.newContext();
const page = await context.newPage();
- let contextClosed = false;
let pageClosed = false;
- context.on('close', e => contextClosed = true);
page.on('close', e => pageClosed = true);
- await browserServer.close();
- expect(contextClosed).toBeTruthy();
+ await Promise.all([
+ new Promise(f => context.on('close', f)),
+ browserServer.close()
+ ]);
expect(pageClosed).toBeTruthy();
});
});