fix(test): fix flaky interception test

This commit is contained in:
Joel Einbinder 2020-01-23 13:14:42 -08:00
parent b4209e9dc8
commit 36c403cb5c

View file

@ -566,13 +566,17 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
await page.setRequestInterception(true);
expect(await page.evaluate(() => navigator.onLine)).toBe(true);
let intercepted;
page.on('request', async request => {
intercepted = true;
await page.setRequestInterception(false);
});
const finished = new Promise(callback => {
page.on('request', async request => {
intercepted = true;
await page.setRequestInterception(false);
callback();
});
})
const response = await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
expect(intercepted).toBe(true);
expect(response.status()).toBe(200);
await finished;
});
});