From 36c403cb5c2c61678548c1d4514b4eb8fadc2df3 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Thu, 23 Jan 2020 13:14:42 -0800 Subject: [PATCH] fix(test): fix flaky interception test --- test/interception.spec.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/interception.spec.js b/test/interception.spec.js index 1cb70b3455..1f64ccf17c 100644 --- a/test/interception.spec.js +++ b/test/interception.spec.js @@ -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; }); });