test: fix random tests flakiness (#2770)
These tests were not awaiting `page.evaluate` command, so page could have been closed before the command returned.
This commit is contained in:
parent
f197d2e208
commit
37dbfc2608
@ -53,8 +53,10 @@ module.exports.addTests = function({testRunner, expect, puppeteer}) {
|
|||||||
const context = await browser.createIncognitoBrowserContext();
|
const context = await browser.createIncognitoBrowserContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
page.evaluate(url => window.open(url), server.EMPTY_PAGE);
|
const [popupTarget] = await Promise.all([
|
||||||
const popupTarget = await utils.waitEvent(browser, 'targetcreated');
|
utils.waitEvent(browser, 'targetcreated'),
|
||||||
|
page.evaluate(url => window.open(url), server.EMPTY_PAGE)
|
||||||
|
]);
|
||||||
expect(popupTarget.browserContext()).toBe(context);
|
expect(popupTarget.browserContext()).toBe(context);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
@ -387,10 +387,10 @@ module.exports.addTests = function({testRunner, expect, puppeteer, DeviceDescrip
|
|||||||
});
|
});
|
||||||
it('should trigger correct Log', async({page, server}) => {
|
it('should trigger correct Log', async({page, server}) => {
|
||||||
await page.goto('about:blank');
|
await page.goto('about:blank');
|
||||||
let message;
|
const [message] = await Promise.all([
|
||||||
page.on('console', event => message = event);
|
waitEvent(page, 'console'),
|
||||||
page.evaluate(async url => fetch(url).catch(e => {}), server.EMPTY_PAGE);
|
page.evaluate(async url => fetch(url).catch(e => {}), server.EMPTY_PAGE)
|
||||||
await waitEvent(page, 'console');
|
]);
|
||||||
expect(message.text()).toContain('No \'Access-Control-Allow-Origin\'');
|
expect(message.text()).toContain('No \'Access-Control-Allow-Origin\'');
|
||||||
expect(message.type()).toEqual('error');
|
expect(message.type()).toEqual('error');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user