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:
parent
1ad6134a54
commit
2b231c9e1b
|
|
@ -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');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue