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