From 166c909ab2526570c0b9255131dd342aee245a38 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 13 Sep 2017 22:52:43 -0700 Subject: [PATCH] [tests] fix a few tests to avoid unhandled promise rejection (#778) A few tests were not waiting for navigation to complete. --- test/test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index bb4ce2b0a68..fc3c1a6cb84 100644 --- a/test/test.js +++ b/test/test.js @@ -1514,8 +1514,10 @@ describe('Page', function() { it('should work', SX(async function() { expect(await page.evaluate(() => navigator.userAgent)).toContain('Mozilla'); page.setUserAgent('foobar'); - page.goto(EMPTY_PAGE); - const request = await server.waitForRequest('/empty.html'); + const [request] = await Promise.all([ + server.waitForRequest('/empty.html'), + page.goto(EMPTY_PAGE), + ]); expect(request.headers['user-agent']).toBe('foobar'); })); it('should emulate device user-agent', SX(async function() { @@ -1530,8 +1532,10 @@ describe('Page', function() { await page.setExtraHTTPHeaders({ foo: 'bar' }); - page.goto(EMPTY_PAGE); - const request = await server.waitForRequest('/empty.html'); + const [request] = await Promise.all([ + server.waitForRequest('/empty.html'), + page.goto(EMPTY_PAGE), + ]); expect(request.headers['foo']).toBe('bar'); })); });