[tests] fix a few tests to avoid unhandled promise rejection (#778)

A few tests were not waiting for navigation to complete.
This commit is contained in:
Andrey Lushnikov 2017-09-13 22:52:43 -07:00 committed by GitHub
parent f398e69dbb
commit 166c909ab2

View File

@ -1514,8 +1514,10 @@ describe('Page', function() {
it('should work', SX(async function() { it('should work', SX(async function() {
expect(await page.evaluate(() => navigator.userAgent)).toContain('Mozilla'); expect(await page.evaluate(() => navigator.userAgent)).toContain('Mozilla');
page.setUserAgent('foobar'); page.setUserAgent('foobar');
page.goto(EMPTY_PAGE); const [request] = await Promise.all([
const request = await server.waitForRequest('/empty.html'); server.waitForRequest('/empty.html'),
page.goto(EMPTY_PAGE),
]);
expect(request.headers['user-agent']).toBe('foobar'); expect(request.headers['user-agent']).toBe('foobar');
})); }));
it('should emulate device user-agent', SX(async function() { it('should emulate device user-agent', SX(async function() {
@ -1530,8 +1532,10 @@ describe('Page', function() {
await page.setExtraHTTPHeaders({ await page.setExtraHTTPHeaders({
foo: 'bar' foo: 'bar'
}); });
page.goto(EMPTY_PAGE); const [request] = await Promise.all([
const request = await server.waitForRequest('/empty.html'); server.waitForRequest('/empty.html'),
page.goto(EMPTY_PAGE),
]);
expect(request.headers['foo']).toBe('bar'); expect(request.headers['foo']).toBe('bar');
})); }));
}); });