mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: await all navigations in tests (#1629)
This commit is contained in:
parent
60ba8c3af9
commit
671d464a98
@ -1169,7 +1169,7 @@ describe('Page', function() {
|
|||||||
it('should work with both domcontentloaded and load', async({page, server}) => {
|
it('should work with both domcontentloaded and load', async({page, server}) => {
|
||||||
let response = null;
|
let response = null;
|
||||||
server.setRoute('/one-style.css', (req, res) => response = res);
|
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({
|
const domContentLoadedPromise = page.waitForNavigation({
|
||||||
waitUntil: 'domcontentloaded'
|
waitUntil: 'domcontentloaded'
|
||||||
});
|
});
|
||||||
@ -1184,6 +1184,7 @@ describe('Page', function() {
|
|||||||
expect(bothFired).toBe(false);
|
expect(bothFired).toBe(false);
|
||||||
response.end();
|
response.end();
|
||||||
await bothFiredPromise;
|
await bothFiredPromise;
|
||||||
|
await navigationPromise;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1561,8 +1562,10 @@ describe('Page', function() {
|
|||||||
it('should fire', async({page, server}) => {
|
it('should fire', async({page, server}) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
page.once('pageerror', e => error = e);
|
page.once('pageerror', e => error = e);
|
||||||
page.goto(server.PREFIX + '/error.html');
|
await Promise.all([
|
||||||
await waitForEvents(page, 'pageerror');
|
page.goto(server.PREFIX + '/error.html'),
|
||||||
|
waitForEvents(page, 'pageerror')
|
||||||
|
]);
|
||||||
expect(error.message).toContain('Fancy');
|
expect(error.message).toContain('Fancy');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user