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 various tests (#32014)
Dmitry Gozman5c9ce6b9d948
diff --git a/tests/config/testserver/index.ts b/tests/config/testserver/index.tsindex 0596960f6b..fa20a61762 100644--- a/tests/config/testserver/index.ts+++ b/tests/config/testserver/index.ts@@ -177,6 +177,7 @@ export class TestServer {this._csp.clear();this._extraHeaders.clear();this._gzipRoutes.clear();+ this._server.closeAllConnections();const error = new Error('Static Server has been reset');for (const subscriber of this._requestSubscribers.values())subscriber[rejectSymbol].call(null, error);diff --git a/tests/library/chromium/oopif.spec.ts b/tests/library/chromium/oopif.spec.tsindex 5324e6d155..cc1279b8af 100644--- a/tests/library/chromium/oopif.spec.ts+++ b/tests/library/chromium/oopif.spec.ts@@ -260,8 +260,8 @@ it('should report google.com frame with headed', async ({ browserType, server })it('ElementHandle.boundingBox() should work', async function({ page, browser, server }) {await page.goto(server.PREFIX + '/dynamic-oopif.html');await page.$eval('iframe', iframe => {- iframe.style.width = '500px';- iframe.style.height = '500px';+ iframe.style.width = '520px';+ iframe.style.height = '520px';iframe.style.marginLeft = '42px';iframe.style.marginTop = '17px';});diff --git a/tests/page/elementhandle-scroll-into-view.spec.ts b/tests/page/elementhandle-scroll-into-view.spec.tsindex e2a401ccea..6894b6465c 100644--- a/tests/page/elementhandle-scroll-into-view.spec.ts+++ b/tests/page/elementhandle-scroll-into-view.spec.ts@@ -80,7 +80,9 @@ it('should scroll display:contents into view', async ({ page, browserName, brows`);const div = await page.$('#target');await div.scrollIntoViewIfNeeded();- expect(await page.$eval('#container', e => e.scrollTop)).toBe(350);+ const scrollTop = await page.$eval('#container', e => e.scrollTop);+ // On Android the value is not exact due to various scale conversions.+ expect(Math.abs(scrollTop - 350)).toBeLessThan(1);});it('should work for visibility:hidden element', async ({ page }) => {diff --git a/tests/page/page-add-locator-handler.spec.ts b/tests/page/page-add-locator-handler.spec.tsindex 0062ba15ab..c99dc1d7c4 100644--- a/tests/page/page-add-locator-handler.spec.ts+++ b/tests/page/page-add-locator-handler.spec.ts@@ -87,7 +87,9 @@ test('should work with a custom check', async ({ page, server }) => {}});-test('should work with locator.hover()', async ({ page, server }) => {+test('should work with locator.hover()', async ({ page, server, headless }) => {+ test.skip(!headless, 'Stray hovers in headed mode');+await page.goto(server.PREFIX + '/input/handle-locator.html');await page.addLocatorHandler(page.getByText('This interstitial covers the button'), async () => {diff --git a/tests/playwright-test/ui-mode-test-screencast.spec.ts b/tests/playwright-test/ui-mode-test-screencast.spec.tsindex 7c973f588b..23e4f5872e 100644--- a/tests/playwright-test/ui-mode-test-screencast.spec.ts+++ b/tests/playwright-test/ui-mode-test-screencast.spec.ts@@ -21,13 +21,15 @@ test.describe.configure({ mode: 'parallel', retries });test('should show screenshots', async ({ runUITest }) => {const { page } = await runUITest({'a.test.ts': `- import { test } from '@playwright/test';+ import { test, expect } from '@playwright/test';test('test 1', async ({ page }) => {await page.setContent('<div style="background: red; width: 100%; height: 100%"></div>');+ await expect(page.locator('body')).toBeVisible();await page.waitForTimeout(1000);});test('test 2', async ({ page }) => {- await page.setContent('<div style="background: blue; width: 100%; height: 100%"></div>');+ await page.setContent('<div style="background: blue; width: 100%; height: 100%">hello</div>');+ await expect(page.locator('body')).toHaveText('hello');await page.waitForTimeout(1000);});`,@@ -36,14 +38,10 @@ test('should show screenshots', async ({ runUITest }) => {await expect(page.getByTestId('status-line')).toHaveText('2/2 passed (100%)');await page.getByText('test 1', { exact: true }).click();- await expect(- page.locator('.CodeMirror .source-line-running'),- ).toContainText(`test('test 1', async ({ page }) => {`);+ await expect(page.getByTestId('actions-tree')).toContainText('expect.toBeVisible');await expect(page.locator('.film-strip-frame').first()).toBeVisible();await page.getByText('test 2', { exact: true }).click();- await expect(- page.locator('.CodeMirror .source-line-running'),- ).toContainText(`await page.waitForTimeout(1000);`);+ await expect(page.getByTestId('actions-tree')).toContainText('expect.toHaveText');await expect(page.locator('.film-strip-frame').first()).toBeVisible();});