From 671d464a985caa3df246bdd1d68fc5f2dff23525 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 19 Dec 2017 16:28:39 -0800 Subject: [PATCH] test: await all navigations in tests (#1629) --- test/test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 206a0dc5e59..ea9cc07391a 100644 --- a/test/test.js +++ b/test/test.js @@ -1169,7 +1169,7 @@ describe('Page', function() { it('should work with both domcontentloaded and load', async({page, server}) => { let response = null; server.setRoute('/one-style.css', (req, res) => response = res); - page.goto(server.PREFIX + '/one-style.html'); + const navigationPromise = page.goto(server.PREFIX + '/one-style.html'); const domContentLoadedPromise = page.waitForNavigation({ waitUntil: 'domcontentloaded' }); @@ -1184,6 +1184,7 @@ describe('Page', function() { expect(bothFired).toBe(false); response.end(); await bothFiredPromise; + await navigationPromise; }); }); @@ -1561,8 +1562,10 @@ describe('Page', function() { it('should fire', async({page, server}) => { let error = null; page.once('pageerror', e => error = e); - page.goto(server.PREFIX + '/error.html'); - await waitForEvents(page, 'pageerror'); + await Promise.all([ + page.goto(server.PREFIX + '/error.html'), + waitForEvents(page, 'pageerror') + ]); expect(error.message).toContain('Fancy'); }); });