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: fix/unflake few tests (#39952)
Dmitry Gozman9dd31fe8559c
diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.ymlindex 142cbe6867..9696226636 100644--- a/.github/workflows/tests_secondary.yml+++ b/.github/workflows/tests_secondary.yml@@ -143,7 +143,7 @@ jobs:- uses: ./.github/actions/run-testwith:browsers-to-install: ${{ matrix.browser }} chromium- command: npm run test -- --project=${{ matrix.browser }}-* --headed+ command: npm run test -- --project=${{ matrix.browser }}-* --headed ${{ matrix.os == 'macos-14-xlarge' && '--workers 2' || '' }}bot-name: "${{ matrix.browser }}-headed-${{ matrix.os }}"flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}diff --git a/packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts b/packages/playwright-core/src/utils/isomorphic/protocolFormatter.tsindex ab2731b24c..188d6690d3 100644--- a/packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts+++ b/packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts@@ -30,7 +30,7 @@ function _formatProtocolParam(params: Record<string, string> | undefined, alternconst urlObject = new URL(params[name]);if (urlObject.protocol === 'data:')return urlObject.protocol;- if (urlObject.protocol === 'about:')+ if (['about:', 'chrome:', 'edge:'].includes(urlObject.protocol))return params[name];return urlObject.pathname + urlObject.search;} catch (error) {diff --git a/packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts b/packages/playwright-core/src/utils/isomorphic/trace/traceModel.tsindex c4bb0faccb..5cf326ca1b 100644--- a/packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts+++ b/packages/playwright-core/src/utils/isomorphic/trace/traceModel.ts@@ -117,7 +117,7 @@ export class TraceModel {this.errors = ([] as trace.ErrorTraceEvent[]).concat(...contexts.map(c => c.errors));this.hasSource = contexts.some(c => c.hasSource);this.hasStepData = contexts.some(context => context.origin === 'testRunner');- this.resources = [...contexts.map(c => c.resources)].flat().map(entry => ({ ...entry, id: `${entry.pageref}-${entry.time}-${entry.request.url}` }));+ this.resources = [...contexts.map(c => c.resources)].flat().map(entry => ({ ...entry, id: `${entry.pageref}-${entry.startedDateTime}-${entry.request.url}` }));this.attachments = this.actions.flatMap(action => action.attachments?.map(attachment => ({ ...attachment, callId: action.callId, traceUri })) ?? []);this.visibleAttachments = this.attachments.filter(attachment => !attachment.name.startsWith('_'));diff --git a/tests/config/testserver/index.ts b/tests/config/testserver/index.tsindex c05bd82ec3..68ee850656 100644--- a/tests/config/testserver/index.ts+++ b/tests/config/testserver/index.ts@@ -200,7 +200,8 @@ export class TestServer {reject = r;});promise[fulfillSymbol] = fulfill;- promise[rejectSymbol] = reject;+ const error = new Error(`Request ${path} was not received before the test finished.`);+ promise[rejectSymbol] = () => reject(error);this._requestSubscribers.set(path, promise);return promise;}@@ -214,9 +215,8 @@ export class TestServer {this._upgradeCallback = undefined;this._wsServer.removeAllListeners('connection');this._server.closeAllConnections();- const error = new Error('Static Server has been reset');for (const subscriber of this._requestSubscribers.values())- subscriber[rejectSymbol].call(null, error);+ subscriber[rejectSymbol].call(null);this._requestSubscribers.clear();}diff --git a/tests/library/screencast.spec.ts b/tests/library/screencast.spec.tsindex db57adfee5..fb282bcd24 100644--- a/tests/library/screencast.spec.ts+++ b/tests/library/screencast.spec.ts@@ -23,6 +23,7 @@ import { VideoPlayer } from './videoPlayer';test.skip(({ mode }) => mode !== 'default', 'screencast is not available in remote mode');test.skip(({ video }) => video === 'on', 'conflicts with built-in video recording');+test.slow();test('screencast.start delivers frames via onFrame callback', async ({ browser, server, trace }) => {test.skip(trace === 'on', 'trace=on has different screencast image configuration');diff --git a/tests/page/workers.spec.ts b/tests/page/workers.spec.tsindex fc5b1b81e1..a2769860fb 100644--- a/tests/page/workers.spec.ts+++ b/tests/page/workers.spec.ts@@ -351,6 +351,7 @@ it('should support extra http headers', {it('should support offline', async ({ page, server, browserName }) => {it.fixme(browserName === 'webkit', 'flaky on all platforms');+ it.fixme(browserName === 'firefox', 'does not plumb setOffline into WorkerNavigator::OnLine');const [worker] = await Promise.all([page.waitForEvent('worker'),@@ -358,9 +359,7 @@ it('should support offline', async ({ page, server, browserName }) => {page.goto(server.PREFIX + '/worker/worker.html'),]);await page.context().setOffline(true);- // TODO: Firefox does not plumb setOffline into WorkerNavigator::OnLine.- const expectedOnline = browserName === 'firefox' ? true : false;- await expect.poll(() => worker.evaluate(() => navigator.onLine)).toBe(expectedOnline);+ await expect.poll(() => worker.evaluate(() => navigator.onLine)).toBe(false);expect(await worker.evaluate(() => fetch('/one-style.css').catch(e => 'error'))).toBe('error');await page.context().setOffline(false);await expect.poll(() => worker.evaluate(() => navigator.onLine)).toBe(true);