Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: unflake/remove some tests (#38985)

Dmitry Gozmancf31121cc552
diff --git a/tests/library/agent-perform.spec.ts b/tests/library/agent-perform.spec.ts
index 915915cd80..9cdd91e34f 100644
--- a/tests/library/agent-perform.spec.ts
+++ b/tests/library/agent-perform.spec.ts
@@ -251,7 +251,9 @@ test('perform reports error', async ({ context }) => {
expect(e.message).toContain('Agent refused to perform action:');
});
-test('should dispatch event and respect dispose()', async ({ context, server }) => {
+test('should dispatch event and respect dispose()', async ({ context, server, mode }) => {
+ test.skip(mode !== 'default', 'Different errors due to timing');
+
let apiResponse;
server.setRoute('/api', (req, res) => {
apiResponse = res;
diff --git a/tests/library/inspector/cli-codegen-1.spec.ts b/tests/library/inspector/cli-codegen-1.spec.ts
index a2a5724bc0..7ced183e3b 100644
--- a/tests/library/inspector/cli-codegen-1.spec.ts
+++ b/tests/library/inspector/cli-codegen-1.spec.ts
@@ -107,7 +107,7 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync()
]);
// Do not trigger double click.
- await page.waitForTimeout(1000);
+ await page.waitForTimeout(3000);
const [sources] = await Promise.all([
recorder.waitForOutput('JavaScript', `click();\n await`),
@@ -132,7 +132,7 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync()
]);
// Do not trigger double click.
- await page.waitForTimeout(1000);
+ await page.waitForTimeout(3000);
await Promise.all([
recorder.waitForOutput('JavaScript', `click();\n await`),
diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.ts
index 07397c5663..f76187ecc9 100644
--- a/tests/library/tracing.spec.ts
+++ b/tests/library/tracing.spec.ts
@@ -293,7 +293,6 @@ test('should not include trace resources from the previous chunks', async ({ con
const names = Array.from(resources.keys());
expect(names.filter(n => n.endsWith('.html')).length).toBe(1);
jpegs = names.filter(n => n.endsWith('.jpeg'));
- expect(jpegs.length).toBeGreaterThan(0);
// 1 source file for the test.
expect(names.filter(n => n.endsWith('.txt')).length).toBe(1);
}
diff --git a/tests/mcp/cli.spec.ts b/tests/mcp/cli.spec.ts
index 1809054749..2114f69eb9 100644
--- a/tests/mcp/cli.spec.ts
+++ b/tests/mcp/cli.spec.ts
@@ -110,7 +110,7 @@ test.describe('core', () => {
});
test('check', async ({ cli, server, mcpBrowser }) => {
- const active = mcpBrowser === 'webkit' && process.platform === 'darwin' ? '' : '[active] ';
+ const active = mcpBrowser === 'webkit' && process.platform !== 'linux' ? '' : '[active] ';
server.setContent('/', `<input type="checkbox">`, 'text/html');
await cli('open', server.PREFIX);
await cli('check', 'e2');
@@ -119,7 +119,7 @@ test.describe('core', () => {
});
test('uncheck', async ({ cli, server, mcpBrowser }) => {
- const active = mcpBrowser === 'webkit' && process.platform === 'darwin' ? '' : '[active] ';
+ const active = mcpBrowser === 'webkit' && process.platform !== 'linux' ? '' : '[active] ';
server.setContent('/', `<input type="checkbox" checked>`, 'text/html');
await cli('open', server.PREFIX);
await cli('uncheck', 'e2');
diff --git a/tests/page/expect-misc.spec.ts b/tests/page/expect-misc.spec.ts
index e550d3ca72..16901c8be0 100644
--- a/tests/page/expect-misc.spec.ts
+++ b/tests/page/expect-misc.spec.ts
@@ -565,7 +565,7 @@ test.describe('toBeInViewport', () => {
test('should have good stack', async ({ page }) => {
let error;
try {
- await expect(page.locator('body')).not.toBeInViewport({ timeout: 500 });
+ await expect(page.locator('body')).not.toBeInViewport({ timeout: 3000 });
} catch (e) {
error = e;
}
diff --git a/tests/playwright-test/runner.spec.ts b/tests/playwright-test/runner.spec.ts
index ef90b2ae13..da07cfdf09 100644
--- a/tests/playwright-test/runner.spec.ts
+++ b/tests/playwright-test/runner.spec.ts
@@ -115,52 +115,6 @@ test('should report subprocess creation error', async ({ runInlineTest }, testIn
expect(result.output).toContain('Error: worker process exited unexpectedly (code=42, signal=null)');
});
-test.describe(() => {
- // Since we create worker processes in the same process group, SIGINT is issued concurrently to
- // all processes. Therefore, we might end up with a dead worker before the runner starts to shutdown.
- // This in turn leads to the "worker process exited unexpectedly" error. Retries should help.
- test.describe.configure({ retries: 2 });
-
- test('should ignore subprocess creation error because of SIGINT', async ({ interactWithTestRunner }, testInfo) => {
- test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');
-
- const readyFile = testInfo.outputPath('ready.txt');
- const testProcess = await interactWithTestRunner({
- 'hang.js': `
- require('fs').writeFileSync(${JSON.stringify(readyFile)}, 'ready');
- setInterval(() => {}, 1000);
- `,
- 'preload.js': `
- require('child_process').spawnSync(
- process.argv[0],
- [require('path').resolve('./hang.js')],
- { env: { ...process.env, NODE_OPTIONS: '' } },
- );
- `,
- 'a.spec.js': `
- import { test, expect } from '@playwright/test';
- test('fails', () => {});
- test('skipped', () => {});
- // Infect subprocesses to immediately hang when spawning a worker.
- process.env.NODE_OPTIONS = '--require ${JSON.stringify(testInfo.outputPath('preload.js'))}';
- `
- });
-
- while (!fs.existsSync(readyFile))
- await new Promise(f => setTimeout(f, 100));
- process.kill(-testProcess.process.pid!, 'SIGINT');
-
- const { exitCode } = await testProcess.exited;
- expect.soft(exitCode).toBe(130);
-
- const result = parseTestRunnerOutput(testProcess.output);
- expect.soft(result.passed).toBe(0);
- expect.soft(result.failed).toBe(0);
- expect.soft(result.didNotRun).toBe(2);
- expect.soft(result.output).not.toContain('worker process exited unexpectedly');
- });
-});
-
test('sigint should stop workers', async ({ interactWithTestRunner }) => {
test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');
diff --git a/tests/playwright-test/ui-mode-test-network-tab.spec.ts b/tests/playwright-test/ui-mode-test-network-tab.spec.ts
index 15d87ae64a..79fa8387e5 100644
--- a/tests/playwright-test/ui-mode-test-network-tab.spec.ts
+++ b/tests/playwright-test/ui-mode-test-network-tab.spec.ts
@@ -321,10 +321,10 @@ test('should copy network request', async ({ runUITest, server }) => {
await page.getByRole('tab', { name: 'Network' }).click();
await page.getByRole('listitem').filter({ hasText: 'post-data-1' }).click();
- await page.getByRole('button', { name: 'Copy request' }).hover();
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
+ await page.getByRole('button', { name: 'Copy request' }).hover();
await page.getByRole('button', { name: 'Copy as cURL' }).click();
await expect(async () => {
const curlRequest = await page.evaluate(() => (window as any).__clipboardCall);
@@ -339,6 +339,7 @@ test('should copy network request', async ({ runUITest, server }) => {
}
}).toPass();
+ await page.getByRole('button', { name: 'Copy request' }).hover();
await page.getByRole('button', { name: 'Copy as Fetch' }).click();
await expect(async () => {
const fetchRequest = await page.evaluate(() => (window as any).__clipboardCall);
@@ -348,6 +349,7 @@ test('should copy network request', async ({ runUITest, server }) => {
expect(fetchRequest).toContain(`"method": "POST"`);
}).toPass();
+ await page.getByRole('button', { name: 'Copy request' }).hover();
await page.getByRole('button', { name: 'Copy as Playwright' }).click();
await expect(async () => {
const playwrightRequest = await page.evaluate(() => (window as any).__clipboardCall);
diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts
index 7fdeec6b4d..a81c0351d0 100644
--- a/tests/playwright-test/ui-mode-trace.spec.ts
+++ b/tests/playwright-test/ui-mode-trace.spec.ts
@@ -451,11 +451,11 @@ test('should work behind reverse proxy', { annotation: { type: 'issue', descript
await expect(page.getByTestId('actions-tree')).toMatchAriaSnapshot(`
- tree:
- - treeitem /Before Hooks \\d+[hmsp]+/
- - treeitem /Set content \\d+[hmsp]+/
+ - treeitem /Before Hooks/
+ - treeitem /Set content/
- treeitem /Click.*getByRole/
- treeitem /Expect "toBe"/
- - treeitem /After Hooks \\d+[hmsp]+/
+ - treeitem /After Hooks/
`);
await expect(