fix(test): unflake waitForSelector when browser closes test

This commit is contained in:
Joel Einbinder 2020-01-30 14:10:29 -08:00
parent d590ab93fa
commit a091dfdfce

View file

@ -172,6 +172,10 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
const remote = await playwright.connect(browserApp.connectOptions()); const remote = await playwright.connect(browserApp.connectOptions());
const page = await remote.defaultContext().newPage(); const page = await remote.defaultContext().newPage();
const watchdog = page.waitForSelector('div', { timeout: 60000 }).catch(e => e); 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(); await remote.disconnect();
const error = await watchdog; const error = await watchdog;
expect(error.message).toContain('Protocol error'); expect(error.message).toContain('Protocol error');