fix(test): unflake waitForSelector when browser closes test (#767)

The waitForSelector call might not have made it into the browser by the time we disconnect, resulting in a websocket error instead of a protocol error.
This commit is contained in:
Joel Einbinder 2020-01-30 14:19:30 -08:00 committed by GitHub
parent 1ad6134a54
commit 2b231c9e1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');