From a091dfdfce42806909bc1986466091323e42b116 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Thu, 30 Jan 2020 14:10:29 -0800 Subject: [PATCH] fix(test): unflake waitForSelector when browser closes test --- test/launcher.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/launcher.spec.js b/test/launcher.spec.js index 3f836851a3a91..64e109f0566da 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -172,6 +172,10 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p const remote = await playwright.connect(browserApp.connectOptions()); const page = await remote.defaultContext().newPage(); const watchdog = page.waitForSelector('div', { timeout: 60000 }).catch(e => e); + + // Make sure the previous waitForSelector has time to make it to the browser before we disconnect. + await page.waitForSelector('body'); + await remote.disconnect(); const error = await watchdog; expect(error.message).toContain('Protocol error');