Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: unflake a few tests (#15959)
Dmitry Gozmana94fe361a2f0
diff --git a/tests/library/geolocation.spec.ts b/tests/library/geolocation.spec.tsindex 424b03e43d..30ea11781d 100644--- a/tests/library/geolocation.spec.ts+++ b/tests/library/geolocation.spec.ts@@ -140,12 +140,18 @@ it('watchPosition should be notified', async ({ server, contextFactory }) => {console.log(`lat=${coords.latitude} lng=${coords.longitude}`);}, err => {});});- await context.setGeolocation({ latitude: 0, longitude: 10 });- await page.waitForEvent('console', message => message.text().includes('lat=0 lng=10'));- await context.setGeolocation({ latitude: 20, longitude: 30 });- await page.waitForEvent('console', message => message.text().includes('lat=20 lng=30'));- await context.setGeolocation({ latitude: 40, longitude: 50 });- await page.waitForEvent('console', message => message.text().includes('lat=40 lng=50'));+ await Promise.all([+ page.waitForEvent('console', message => message.text().includes('lat=0 lng=10')),+ context.setGeolocation({ latitude: 0, longitude: 10 }),+ ]);+ await Promise.all([+ page.waitForEvent('console', message => message.text().includes('lat=20 lng=30')),+ context.setGeolocation({ latitude: 20, longitude: 30 }),+ ]);+ await Promise.all([+ page.waitForEvent('console', message => message.text().includes('lat=40 lng=50')),+ context.setGeolocation({ latitude: 40, longitude: 50 }),+ ]);const allMessages = messages.join('|');expect(allMessages).toContain('lat=0 lng=10');diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex 05df2f3201..2e17aeea5b 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -55,18 +55,6 @@ test.beforeAll(async function recordTrace({ browser, browserName, browserType, s}await doClick();- // Make sure resources arrive in a predictable order.- const htmlDone = page.waitForEvent('requestfinished', request => request.url().includes('frame.html'));- const styleDone = page.waitForEvent('requestfinished', request => request.url().includes('style.css'));- await page.route(server.PREFIX + '/frames/style.css', async route => {- await htmlDone;- await route.continue();- });- await page.route(server.PREFIX + '/frames/script.js', async route => {- await styleDone;- await route.continue();- });-await Promise.all([page.waitForNavigation(),page.waitForTimeout(200).then(() => page.goto(server.PREFIX + '/frames/frame.html'))@@ -99,14 +87,9 @@ test('should open simple trace viewer', async ({ showTraceViewer }) => {/page.evaluate/,/page.evaluate/,/page.click"Click"/,- /page.waitForEvent/,- /page.waitForEvent/,- /page.route/,/page.waitForNavigation/,/page.waitForTimeout/,/page.gotohttp:\/\/localhost:\d+\/frames\/frame.html/,- /route.continue/,- /route.continue/,/page.setViewportSize/,]);});@@ -200,11 +183,9 @@ test('should have network requests', async ({ showTraceViewer }) => {const traceViewer = await showTraceViewer([traceFile]);await traceViewer.selectAction('http://localhost');await traceViewer.showNetworkTab();- await expect(traceViewer.networkRequests).toHaveText([- '200GETframe.htmltext/html',- '200GETstyle.csstext/css',- '200GETscript.jsapplication/javascript',- ]);+ await expect(traceViewer.networkRequests).toContainText(['200GETframe.htmltext/html']);+ await expect(traceViewer.networkRequests).toContainText(['200GETstyle.csstext/css']);+ await expect(traceViewer.networkRequests).toContainText(['200GETscript.jsapplication/javascript']);});test('should show snapshot URL', async ({ page, runAndTrace, server }) => {diff --git a/tests/playwright-test/hooks.spec.ts b/tests/playwright-test/hooks.spec.tsindex 8e4a4eb940..efb12eb381 100644--- a/tests/playwright-test/hooks.spec.ts+++ b/tests/playwright-test/hooks.spec.ts@@ -719,10 +719,10 @@ test('test.setTimeout should work separately in beforeAll', async ({ runInlineTe});test('passed', async () => {console.log('\\n%%test');- await new Promise(f => setTimeout(f, 800));+ await new Promise(f => setTimeout(f, 500));});`,- }, { timeout: '1000' });+ }, { timeout: 2000 });expect(result.exitCode).toBe(0);expect(result.passed).toBe(1);expect(result.output.split('\n').filter(line => line.startsWith('%%'))).toEqual([diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.tsindex 1d3d667579..ecb9c1160f 100644--- a/tests/playwright-test/playwright.spec.ts+++ b/tests/playwright-test/playwright.spec.ts@@ -145,7 +145,7 @@ test('should not override use:browserName without projects', async ({ runInlineT`,'a.test.ts': `const { test } = pwt;- test('pass', async ({ page, browserName }) => {+ test('pass', async ({ browserName }) => {console.log('\\n%%browser=' + browserName);});`,@@ -165,7 +165,7 @@ test('should override use:browserName with --browser', async ({ runInlineTest })`,'a.test.ts': `const { test } = pwt;- test('pass', async ({ page, browserName }) => {+ test('pass', async ({ browserName }) => {console.log('\\n%%browser=' + browserName);});`,