Skip to content

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

test: fix/unflake a few tests (#39871)

Dmitry Gozman51784964ed3e
diff --git a/tests/library/browser-server.spec.ts b/tests/library/browser-server.spec.ts
index cfec19ec75..11fc81fd59 100644
--- a/tests/library/browser-server.spec.ts
+++ b/tests/library/browser-server.spec.ts
@@ -28,7 +28,7 @@ it.beforeEach(({}, testInfo) => {
it('should start and stop pipe server', async ({ browserType, browser }) => {
const serverInfo = await (browser as any)._register('default', {});
expect(serverInfo).toEqual(expect.objectContaining({
- pipeName: expect.stringMatching(/browser@.*\.sock/),
+ pipeName: expect.stringMatching(/browser@/),
}));
const browser2 = await (browserType as any).connect(serverInfo.pipeName);
diff --git a/tests/library/browsercontext-reuse.spec.ts b/tests/library/browsercontext-reuse.spec.ts
index dc92fc41c4..c8457eabcc 100644
--- a/tests/library/browsercontext-reuse.spec.ts
+++ b/tests/library/browsercontext-reuse.spec.ts
@@ -120,6 +120,7 @@ for (const scenario of ['launch', 'connect'] as const) {
<title>Page Title</title>
<script>
navigator.serviceWorker.register('sw.js');
+ window.activationPromise = new Promise(resolve => navigator.serviceWorker.oncontrollerchange = resolve);
</script>
`);
});
@@ -142,6 +143,7 @@ for (const scenario of ['launch', 'connect'] as const) {
let page = await context.newPage();
await page.goto(server.PREFIX + '/page.html');
await expect(page).toHaveTitle('Page Title');
+ await page.evaluate(() => window['activationPromise']);
context = await reusedContext();
page = context.pages()[0];
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index a3e0d4cc19..bc03f5a6e2 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -1121,7 +1121,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
'a.test.js': `
import { test, expect } from '@playwright/test';
test('passing', async ({ page }, testInfo) => {
- await testInfo.attach('screenshot', { body: await page.screenshot(), contentType: 'image/png' });
+ await testInfo.attach('screenshot', { body: Buffer.from('d'), contentType: 'image/png' });
await testInfo.attach('some-pdf', { body: Buffer.from('foo'), contentType: 'application/pdf' });
await testInfo.attach('madeup-contentType', { body: Buffer.from('bar'), contentType: 'madeup' });
@@ -1136,7 +1136,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await page.getByRole('link', { name: 'passing' }).click();
const expectedAttachments = [
- ['screenshot', 'screenshot.png', '7a33d5db6370b6de345e990751aa1f1da65ad675.png'],
+ ['screenshot', 'screenshot.png', '3c363836cf4e16666669a25da280a1865c2d2874.png'],
['some-pdf', 'some-pdf.pdf', '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33.pdf'],
['madeup-contentType', 'madeup-contentType.dat', '62cdb7020ff920e5aa642c3d4066950dd1f01f4d.dat'],
['screenshot-that-already-has-an-extension-with-madeup.png', 'screenshot-that-already-has-an-extension-with-madeup.png', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.png'],
@@ -1155,7 +1155,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
const files = await fs.promises.readdir(path.join(testInfo.outputPath('playwright-report'), 'data'));
expect(new Set(files)).toEqual(new Set([
- '7a33d5db6370b6de345e990751aa1f1da65ad675.png', // screenshot
+ '3c363836cf4e16666669a25da280a1865c2d2874.png', // screenshot
'0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33.pdf', // some-pdf
'62cdb7020ff920e5aa642c3d4066950dd1f01f4d.dat', // madeup-contentType
'86f7e437faa5a7fce15d1ddcb9eaeaea377667b8.png', // screenshot-that-already-has-an-extension-with-madeup.png
diff --git a/tests/playwright-test/ui-mode-test-output.spec.ts b/tests/playwright-test/ui-mode-test-output.spec.ts
index 1219561893..847d9f2420 100644
--- a/tests/playwright-test/ui-mode-test-output.spec.ts
+++ b/tests/playwright-test/ui-mode-test-output.spec.ts
@@ -203,7 +203,7 @@ test('should format console messages in page', async ({ runUITest }, testInfo) =
await expect(label).toHaveCSS('color', 'rgb(255, 0, 0)');
await expect(label).toHaveCSS('font-weight', '700');
// blue should not be used, should inherit color red.
- await expect(label).toHaveCSS('outline', 'rgb(255, 0, 0) none 0px');
+ await expect(label).toHaveCSS('outline-color', 'rgb(255, 0, 0)');
const link = page.getByText('https://fb.me/react-devtools');
await expect(link).toHaveCSS('color', 'rgb(0, 0, 255)');