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/fix/skip a few tests (#40662)
Dmitry Gozman9a533e12b977
diff --git a/tests/library/browsertype-launch.spec.ts b/tests/library/browsertype-launch.spec.tsindex a66ccf1222..11f123c863 100644--- a/tests/library/browsertype-launch.spec.ts+++ b/tests/library/browsertype-launch.spec.ts@@ -61,15 +61,14 @@ it('should throw if page argument is passed', async ({ browserType, browserName,expect(waitError!.message).toContain('can not specify page');});-it('should reject if launched browser fails immediately', async ({ mode, browserType, asset, isWindows, channel }) => {+it('should reject if launched browser fails immediately', async ({ mode, browserType, asset, channel }) => {it.skip(mode.startsWith('service'));- let waitError: Error | undefined;- await browserType.launch({ executablePath: asset('dummy_bad_browser_executable.js') }).catch(e => waitError = e);+ const error = await browserType.launch({ executablePath: asset('dummy_bad_browser_executable.js') }).catch(e => e);if (channel === 'webkit-wsl')- expect(waitError!.message).toContain('Cannot specify executablePath when using the \"webkit-wsl\" channel.');+ expect(error.message).toContain('Cannot specify executablePath when using the \"webkit-wsl\" channel.');else- expect(waitError!.message).toContain(isWindows ? 'browserType.launch: spawn UNKNOWN' : 'Browser logs:');+ expect(error.message).toMatch(/browserType\.launch(.|\n)*(spawn UNKNOWN|spawn EFTYPE|Browser logs:)/gim);});it('should reject if executable path is invalid', async ({ browserType, mode, channel }) => {@@ -92,22 +91,14 @@ it('should handle timeout', async ({ browserType, mode }) => {expect(error!.message).toContain(`<launched> pid=`);});-it('should handle exception', async ({ browserType, mode }) => {- it.skip(mode !== 'default');-- const e = new Error('Dummy');- const options = { __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };- const error = await browserType.launch(options).catch(e => e);- expect(error!.message).toContain('Dummy');-});--it('should report launch log', async ({ browserType, mode }) => {+it('should handle exception and report launch log', async ({ browserType, mode }) => {it.skip(mode !== 'default');const e = new Error('Dummy');- const options = { __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };+ const options = { __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 15000 };const error = await browserType.launch(options).catch(e => e);- expect(error!.message).toContain('<launching>');+ expect(error.message).toContain('Dummy');+ expect(error.message).toContain('<launching>');});it('should accept objects as options', async ({ mode, browserType }) => {diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex c415e29909..237dd89130 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -200,7 +200,7 @@ test('should filter actions by text', async ({ showTraceViewer }) => {const fullCount = await traceViewer.actionTitles.count();await filterInput.fill('Click');await expect(traceViewer.actionTitles.filter({ hasText: 'Click' }).first()).toBeVisible();- expect(await traceViewer.actionTitles.count()).toBeLessThan(fullCount);+ await expect.poll(() => traceViewer.actionTitles.count()).toBeLessThan(fullCount);await filterInput.fill('');await expect(traceViewer.actionTitles).toHaveCount(fullCount);diff --git a/tests/page/expect-timeout.spec.ts b/tests/page/expect-timeout.spec.tsindex 6f54e295e3..963aaa9bcd 100644--- a/tests/page/expect-timeout.spec.ts+++ b/tests/page/expect-timeout.spec.ts@@ -114,7 +114,7 @@ Call log:test('should not miss element that appears between retries before the deadline', async ({ page }) => {await page.setContent(`<div id="target" style="display:none">content</div>`);await page.evaluate(() => {- setTimeout(() => {+ window.builtins.setTimeout(() => {document.getElementById('target')!.style.display = 'block';}, 1500);});diff --git a/tests/page/page-basic.spec.ts b/tests/page/page-basic.spec.tsindex e14c4a7bb7..b0ba37ace0 100644--- a/tests/page/page-basic.spec.ts+++ b/tests/page/page-basic.spec.ts@@ -180,7 +180,9 @@ it('frame.press should work', async ({ page, server }) => {expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a');});-it('has navigator.webdriver set to true', async ({ page }) => {+it('has navigator.webdriver set to true', async ({ page, isAndroid }) => {+ it.fixme(isAndroid);+expect(await page.evaluate(() => navigator.webdriver)).toBe(true);});diff --git a/tests/page/page-emulate-media.spec.ts b/tests/page/page-emulate-media.spec.tsindex 63c9ec0894..6e6b6cbb47 100644--- a/tests/page/page-emulate-media.spec.ts+++ b/tests/page/page-emulate-media.spec.ts@@ -193,8 +193,10 @@ it('should emulate contrast ', async ({ page }) => {await expect(page).toMatchMedia('(prefers-contrast: no-preference)');});-it('should report hover and fine pointer for desktop', async ({ page, browserName, headless, isLinux }) => {+it('should report hover and fine pointer for desktop', async ({ page, browserName, headless, isLinux, isAndroid }) => {it.fail(browserName === 'firefox' && isLinux && headless, 'https://github.com/microsoft/playwright/issues/38835');+ it.skip(isAndroid);+await expect(page).toMatchMedia('(hover: hover)');await expect(page).toMatchMedia('(pointer: fine)');});diff --git a/tests/page/page-goto.spec.ts b/tests/page/page-goto.spec.tsindex a3f518665b..bf8e9ecf4c 100644--- a/tests/page/page-goto.spec.ts+++ b/tests/page/page-goto.spec.ts@@ -407,8 +407,8 @@ it('should fail when exceeding browser context navigation timeout', async ({ pagexpect(error).toBeInstanceOf(playwright.errors.TimeoutError);});-it('should fail when exceeding default maximum timeout', async ({ page, server, playwright, isAndroid }) => {- it.skip(isAndroid, 'No context per test');+it('should fail when exceeding default maximum timeout', async ({ page, server, playwright, isAndroid, isElectron }) => {+ it.skip(isAndroid || isElectron, 'No context per test');// Hang for request to the empty.htmlserver.setRoute('/empty.html', (req, res) => { });@@ -423,8 +423,8 @@ it('should fail when exceeding default maximum timeout', async ({ page, server,expect(error).toBeInstanceOf(playwright.errors.TimeoutError);});-it('should fail when exceeding browser context timeout', async ({ page, server, playwright, isAndroid }) => {- it.skip(isAndroid, 'No context per test');+it('should fail when exceeding browser context timeout', async ({ page, server, playwright, isAndroid, isElectron }) => {+ it.skip(isAndroid || isElectron, 'No context per test');// Hang for request to the empty.htmlserver.setRoute('/empty.html', (req, res) => { });diff --git a/tests/page/page-network-response.spec.ts b/tests/page/page-network-response.spec.tsindex a6057ba481..12fa8da1ec 100644--- a/tests/page/page-network-response.spec.ts+++ b/tests/page/page-network-response.spec.ts@@ -64,8 +64,10 @@ it('should return uncompressed text', async ({ page, server }) => {expect(await response.text()).toBe('{"foo": "bar"}\n');});-it('should return uncompressed text for brotli encoding', async ({ page, server, browserName }) => {+it('should return uncompressed text for brotli encoding', async ({ page, server, browserName, isAndroid }) => {it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/39160');+ it.fixme(isAndroid, 'net::ERR_CONTENT_DECODING_FAILED');+const text = '{"foo": "bar"}\n';const compressed = zlib.brotliCompressSync(Buffer.from(text));server.setRoute('/brotli.json', (req, res) => {diff --git a/tests/page/page-request-continue.spec.ts b/tests/page/page-request-continue.spec.tsindex 496732a4c3..0166f520fe 100644--- a/tests/page/page-request-continue.spec.ts+++ b/tests/page/page-request-continue.spec.ts@@ -139,8 +139,10 @@ it('should not allow changing protocol when overriding url', async ({ page, servexpect(error.message).toContain('New URL must have same protocol as overridden URL');});-it('should not throw if request was cancelled by the page', async ({ page, server, browserName }) => {+it('should not throw if request was cancelled by the page', async ({ page, server, isAndroid }) => {it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28490' });+ it.fixme(isAndroid, 'net::ERR_CONNECTION_RESET');+let interceptCallback;const interceptPromise = new Promise<Route>(f => interceptCallback = f);await page.route('**/data.json', route => interceptCallback(route));