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}) => {
|
||||
let response = null;
|
||||
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({
|
||||
waitUntil: 'domcontentloaded'
|
||||
});
|
||||
@ -1184,6 +1184,7 @@ describe('Page', function() {
|
||||
expect(bothFired).toBe(false);
|
||||
response.end();
|
||||
await bothFiredPromise;
|
||||
await navigationPromise;
|
||||
});
|
||||
});
|
||||
|
||||
@ -1561,8 +1562,10 @@ describe('Page', function() {
|
||||
it('should fire', async({page, server}) => {
|
||||
let error = null;
|
||||
page.once('pageerror', e => error = e);
|
||||
page.goto(server.PREFIX + '/error.html');
|
||||
await waitForEvents(page, 'pageerror');
|
||||
await Promise.all([
|
||||
page.goto(server.PREFIX + '/error.html'),
|
||||
waitForEvents(page, 'pageerror')
|
||||
]);
|
||||
expect(error.message).toContain('Fancy');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user