Skip to content

Commit

Permalink
fix(test): unflake waitForSelector when browser closes test (#767)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JoelEinbinder authored Jan 30, 2020
1 parent 1ad6134 commit 2b231c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/launcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 2b231c9

Please sign in to comment.