test: unflake a few tests (#9142)

This commit is contained in:
Dmitry Gozman 2021-09-24 15:05:20 -07:00 committed by GitHub
parent db6c55af51
commit 418ce9c17e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 15 deletions

View file

@ -121,9 +121,10 @@ it.describe('Drag and drop', () => {
});
});
it('should respect the drop effect', async ({page, browserName, platform}) => {
it('should respect the drop effect', async ({page, browserName, platform, trace}) => {
it.fixme(browserName === 'webkit' && platform !== 'linux', 'WebKit doesn\'t handle the drop effect correctly outside of linux.');
it.fixme(browserName === 'firefox');
it.slow(!!trace);
expect(await testIfDropped('copy', 'copy')).toBe(true);
expect(await testIfDropped('copy', 'move')).toBe(false);

View file

@ -124,6 +124,13 @@ test.beforeAll(async function recordTrace({ browser, browserName, browserType, s
}
await doClick();
const styleDone = page.waitForEvent('requestfinished', request => request.url().includes('style.css'));
await page.route(server.PREFIX + '/frames/script.js', async route => {
// Make sure script arrives after style for predictable results.
await styleDone;
await route.continue();
});
await Promise.all([
page.waitForNavigation(),
page.waitForTimeout(200).then(() => page.goto(server.PREFIX + '/frames/frame.html'))
@ -149,15 +156,16 @@ test('should show empty trace viewer', async ({ showTraceViewer }, testInfo) =>
test('should open simple trace viewer', async ({ showTraceViewer }) => {
const traceViewer = await showTraceViewer(traceFile);
await expect(traceViewer.actionTitles).toHaveText([
/page.gotodata:text\/html,<html>Hello world<\/html>— \d+ms/,
/page.setContent— \d+ms/,
/page.evaluate— \d+ms/,
/page.click"Click"— \d+ms/,
/page.waitForNavigation— \d+ms/,
/page.waitForTimeout— \d+ms/,
/page.gotohttp:\/\/localhost:\d+\/frames\/frame.html— \d+ms/,
/page.setViewportSize— \d+ms/,
/page.hoverbody— \d+ms/,
/page.gotodata:text\/html,<html>Hello world<\/html>— [\d.ms]+/,
/page.setContent— [\d.ms]+/,
/page.evaluate— [\d.ms]+/,
/page.click"Click"— [\d.ms]+/,
/page.waitForEvent— [\d.ms]+/,
/page.waitForNavigation— [\d.ms]+/,
/page.waitForTimeout— [\d.ms]+/,
/page.gotohttp:\/\/localhost:\d+\/frames\/frame.html— [\d.ms]+/,
/page.setViewportSize— [\d.ms]+/,
/page.hoverbody— [\d.ms]+/,
]);
});
@ -200,7 +208,7 @@ test('should show params and return value', async ({ showTraceViewer, browserNam
const traceViewer = await showTraceViewer(traceFile);
await traceViewer.selectAction('page.evaluate');
await expect(traceViewer.callLines).toHaveText([
/page.evaluate — \d+ms/,
/page.evaluate — [\d.ms]+/,
'expression: "({↵ a↵ }) => {↵ console.log(\'Info\');↵ console.warn(\'Warning\');↵ con…"',
'isFunction: true',
'arg: {"a":"paramA","b":4}',

View file

@ -261,10 +261,9 @@ it.describe('screencast', () => {
const saveAsPath = testInfo.outputPath('my-video.webm');
const error = await popup.video().saveAs(saveAsPath).catch(e => e);
// WebKit pauses renderer before win.close() and actually writes something.
if (browserName === 'webkit')
expect(fs.existsSync(saveAsPath)).toBeTruthy();
else
// WebKit pauses renderer before win.close() and actually writes something,
// and other browsers are sometimes fast as well.
if (!fs.existsSync(saveAsPath))
expect(error.message).toContain('Page did not produce any video frames');
});