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'); })); });