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
chore: roll stable test runner (#40192)
Pavel Feldman47154ab04840
diff --git a/packages/playwright/package.json b/packages/playwright/package.jsonindex 4241d97a47..64c80e7ca4 100644--- a/packages/playwright/package.json+++ b/packages/playwright/package.json@@ -24,6 +24,7 @@"./lib/mcp/index": "./lib/mcp/index.js","./lib/program": "./lib/program.js","./lib/runner": "./lib/runner/index.js",+ "./lib/isomorphic": "./lib/isomorphic/index.js","./lib/transform/babelBundle": "./lib/transform/babelBundle.js","./jsx-runtime": {"import": "./jsx-runtime.mjs",diff --git a/packages/playwright/src/isomorphic/index.ts b/packages/playwright/src/isomorphic/index.tsnew file mode 100644index 0000000000..4fdf3efc6b--- /dev/null+++ b/packages/playwright/src/isomorphic/index.ts@@ -0,0 +1,17 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export * from './testServerConnection';diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.tsindex 3a28b4993d..37c9fe77ce 100644--- a/packages/playwright/src/reporters/base.ts+++ b/packages/playwright/src/reporters/base.ts@@ -17,13 +17,13 @@import path from 'path';import realColors from 'colors/safe';-import * as getEastAsianWidth from 'get-east-asian-width';import { noColors } from '@isomorphic/colors';import { msToString } from '@isomorphic/formatUtils';import { parseErrorStack } from '@isomorphic/stackTrace';import { getPackageManagerExecCommand } from '@utils/env';+import { fitToWidth } from '@utils/stringWidth';-import { ansiRegex, resolveReporterOutputPath, stripAnsiEscapes } from '../util';+import { resolveReporterOutputPath, stripAnsiEscapes } from '../util';import type { ReporterV2 } from './reporterV2';import type { FullConfig, FullResult, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter';@@ -618,58 +618,6 @@ export function prepareErrorStack(stack: string): {return parseErrorStack(stack, path.sep, !!process.env.PWDEBUGIMPL);}-function characterWidth(c: string) {- return getEastAsianWidth.eastAsianWidth(c.codePointAt(0)!);-}--function stringWidth(v: string) {- let width = 0;- for (const { segment } of new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(v))- width += characterWidth(segment);- return width;-}--function suffixOfWidth(v: string, width: number) {- const segments = [...new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(v)];- let suffixBegin = v.length;- for (const { segment, index } of segments.reverse()) {- const segmentWidth = stringWidth(segment);- if (segmentWidth > width)- break;- width -= segmentWidth;- suffixBegin = index;- }- return v.substring(suffixBegin);-}--// Leaves enough space for the "prefix" to also fit.-export function fitToWidth(line: string, width: number, prefix?: string): string {- const prefixLength = prefix ? stripAnsiEscapes(prefix).length : 0;- width -= prefixLength;- if (stringWidth(line) <= width)- return line;-- // Even items are plain text, odd items are control sequences.- const parts = line.split(ansiRegex);- const taken: string[] = [];- for (let i = parts.length - 1; i >= 0; i--) {- if (i % 2) {- // Include all control sequences to preserve formatting.- taken.push(parts[i]);- } else {- let part = suffixOfWidth(parts[i], width);- const wasTruncated = part.length < parts[i].length;- if (wasTruncated && parts[i].length > 0) {- // Add ellipsis if we are truncating.- part = '\u2026' + suffixOfWidth(parts[i], width - 1);- }- taken.push(part);- width -= stringWidth(part);- }- }- return taken.reverse().join('');-}-function resolveFromEnv(name: string): string | undefined {const value = process.env[name];if (value)diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.tsindex cb23beacaf..29df729b48 100644--- a/packages/playwright/src/reporters/html.ts+++ b/packages/playwright/src/reporters/html.ts@@ -27,7 +27,7 @@ import { MultiMap } from '@isomorphic/multimap';import { calculateSha1 } from '@utils/crypto';import { copyFileAndMakeWritable, removeFolders, sanitizeForFilePath, toPosixPath } from '@utils/fileUtils';import { getPackageManagerExecCommand } from '@utils/env';-import { HttpServer } from '@utils/httpServer';+import { serveFolder } from '@utils/httpServer';import { gracefullyProcessExitDoNotHang } from '@utils/processLauncher';import { CommonReporterOptions, formatError, formatResultFailure, internalScreen } from './base';@@ -222,7 +222,7 @@ export async function showHTMLReport(reportFolder: string | undefined, host: strgracefullyProcessExitDoNotHang(1);return;}- const server = startHtmlReportServer(folder);+ const server = serveFolder(folder);await server.start({ port, host, preferredPort: port ? undefined : 9323 });let url = server.urlPrefix('human-readable');writeLine('');@@ -234,26 +234,6 @@ export async function showHTMLReport(reportFolder: string | undefined, host: strawait new Promise(() => {});}-export function startHtmlReportServer(folder: string): HttpServer {- const server = new HttpServer();- server.routePrefix('/', (request, response) => {- let relativePath = new URL('http://localhost' + request.url).pathname;- if (relativePath.startsWith('/trace/file')) {- const url = new URL('http://localhost' + request.url!);- try {- return server.serveFile(request, response, url.searchParams.get('path')!);- } catch (e) {- return false;- }- }- if (relativePath === '/')- relativePath = '/index.html';- const absolutePath = path.join(folder, ...relativePath.split('/'));- return server.serveFile(request, response, absolutePath);- });- return server;-}-type DataMap = Map<string, { testFile: TestFile, testFileSummary: TestFileSummary }>;class HtmlBuilder {diff --git a/packages/utils/httpServer.ts b/packages/utils/httpServer.tsindex c571143410..6f11e83aab 100644--- a/packages/utils/httpServer.ts+++ b/packages/utils/httpServer.ts@@ -220,3 +220,23 @@ export class HttpServer {}}}++export function serveFolder(folder: string): HttpServer {+ const server = new HttpServer();+ server.routePrefix('/', (request, response) => {+ let relativePath = new URL('http://localhost' + request.url).pathname;+ if (relativePath.startsWith('/trace/file')) {+ const url = new URL('http://localhost' + request.url!);+ try {+ return server.serveFile(request, response, url.searchParams.get('path')!);+ } catch (e) {+ return false;+ }+ }+ if (relativePath === '/')+ relativePath = '/index.html';+ const absolutePath = path.join(folder, ...relativePath.split('/'));+ return server.serveFile(request, response, absolutePath);+ });+ return server;+}diff --git a/packages/utils/index.ts b/packages/utils/index.tsindex b2e95d7651..42d4a24308 100644--- a/packages/utils/index.ts+++ b/packages/utils/index.ts@@ -31,6 +31,7 @@ export * from './profiler';export * from './serializedFS';export * from './socksProxy';export * from './spawnAsync';+export * from './stringWidth';export * from './task';export * from './wsServer';export * from './zipFile';diff --git a/packages/utils/stringWidth.ts b/packages/utils/stringWidth.tsnew file mode 100644index 0000000000..2081876a4b--- /dev/null+++ b/packages/utils/stringWidth.ts@@ -0,0 +1,69 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import * as getEastAsianWidth from 'get-east-asian-width';+import { ansiRegex, stripAnsiEscapes } from '@isomorphic/stringUtils';++function characterWidth(c: string) {+ return getEastAsianWidth.eastAsianWidth(c.codePointAt(0)!);+}++export function stringWidth(v: string) {+ let width = 0;+ for (const { segment } of new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(v))+ width += characterWidth(segment);+ return width;+}++function suffixOfWidth(v: string, width: number) {+ const segments = [...new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(v)];+ let suffixBegin = v.length;+ for (const { segment, index } of segments.reverse()) {+ const segmentWidth = stringWidth(segment);+ if (segmentWidth > width)+ break;+ width -= segmentWidth;+ suffixBegin = index;+ }+ return v.substring(suffixBegin);+}++export function fitToWidth(line: string, width: number, prefix?: string): string {+ const prefixLength = prefix ? stripAnsiEscapes(prefix).length : 0;+ width -= prefixLength;+ if (stringWidth(line) <= width)+ return line;++ // Even items are plain text, odd items are control sequences.+ const parts = line.split(ansiRegex);+ const taken: string[] = [];+ for (let i = parts.length - 1; i >= 0; i--) {+ if (i % 2) {+ // Include all control sequences to preserve formatting.+ taken.push(parts[i]);+ } else {+ let part = suffixOfWidth(parts[i], width);+ const wasTruncated = part.length < parts[i].length;+ if (wasTruncated && parts[i].length > 0) {+ // Add ellipsis if we are truncating.+ part = '\u2026' + suffixOfWidth(parts[i], width - 1);+ }+ taken.push(part);+ width -= stringWidth(part);+ }+ }+ return taken.reverse().join('');+}diff --git a/tests/playwright-test/fit-to-width.spec.ts b/tests/playwright-test/fit-to-width.spec.tsindex 9aa6125fd1..003939aeec 100644--- a/tests/playwright-test/fit-to-width.spec.ts+++ b/tests/playwright-test/fit-to-width.spec.ts@@ -14,21 +14,20 @@* limitations under the License.*/-import { base } from '../../packages/playwright/lib/runner';-const { fitToWidth } = base;+import { utils } from '../../packages/playwright-core/lib/coreBundle';import { test, expect } from './playwright-test-fixtures';test('chinese characters', () => {- expect(fitToWidth('你你好', 3)).toBe('…好');- expect(fitToWidth('你好你好', 4)).toBe('…好');+ expect(utils.fitToWidth('你你好', 3)).toBe('…好');+ expect(utils.fitToWidth('你好你好', 4)).toBe('…好');});test('surrogate pairs', () => {- expect(fitToWidth('🫣🤗', 2)).toBe('…');- expect(fitToWidth('🫣🤗', 3)).toBe('…🤗');- expect(fitToWidth('🚄🚄', 1)).toBe('…');- expect(fitToWidth('🚄🚄', 2)).toBe('…');- expect(fitToWidth('🚄🚄', 3)).toBe('…🚄');- expect(fitToWidth('🚄🚄', 4)).toBe('🚄🚄');- expect(fitToWidth('🧑🧑🧒🧑🧑🧒🧑🧑🧒', 4)).toBe('…🧑🧑🧒');+ expect(utils.fitToWidth('🫣🤗', 2)).toBe('…');+ expect(utils.fitToWidth('🫣🤗', 3)).toBe('…🤗');+ expect(utils.fitToWidth('🚄🚄', 1)).toBe('…');+ expect(utils.fitToWidth('🚄🚄', 2)).toBe('…');+ expect(utils.fitToWidth('🚄🚄', 3)).toBe('…🚄');+ expect(utils.fitToWidth('🚄🚄', 4)).toBe('🚄🚄');+ expect(utils.fitToWidth('🧑🧑🧒🧑🧑🧒🧑🧑🧒', 4)).toBe('…🧑🧑🧒');});diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.tsindex cf5064a97b..7c620d85f5 100644--- a/tests/playwright-test/reporter-blob.spec.ts+++ b/tests/playwright-test/reporter-blob.spec.ts@@ -17,8 +17,6 @@import * as fs from 'fs';import type { PlaywrightTestConfig } from '@playwright/test';import path from 'path';-import { html } from '../../packages/playwright/lib/runner';-const { startHtmlReportServer } = html;import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';import { extractZip } from '../../packages/utils/third_party/extractZip';import * as yazl from 'yazl';@@ -39,7 +37,7 @@ const test = baseTest.extend<{let server: HttpServer | undefined;await use(async (reportFolder?: string) => {reportFolder ??= test.info().outputPath('playwright-report');- server = startHtmlReportServer(reportFolder) as HttpServer;+ server = utils.serveFolder(reportFolder);await server.start();await page.goto(server.urlPrefix('precise'));});diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex 951d3d826e..d9a9bc2372 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -18,8 +18,6 @@ import fs from 'fs';import path from 'path';import url from 'url';import { test as baseTest, expect as baseExpect, createImage } from './playwright-test-fixtures';-import { html } from '../../packages/playwright/lib/runner';-const { startHtmlReportServer } = html;import { iso, utils } from '../../packages/playwright-core/lib/coreBundle';type HttpServer = utils.HttpServer;@@ -32,7 +30,7 @@ const test = baseTest.extend<{ showReport: (reportFolder?: string) => Promise<volet server: HttpServer | undefined;await use(async (reportFolder?: string) => {reportFolder ??= testInfo.outputPath('playwright-report');- server = startHtmlReportServer(reportFolder) as HttpServer;+ server = utils.serveFolder(reportFolder);await server.start();await page.goto(server.urlPrefix('precise'));});diff --git a/tests/playwright-test/stable-test-runner/package-lock.json b/tests/playwright-test/stable-test-runner/package-lock.jsonindex 183dbd2d58..e5d8fc3e45 100644--- a/tests/playwright-test/stable-test-runner/package-lock.json+++ b/tests/playwright-test/stable-test-runner/package-lock.json@@ -5,16 +5,16 @@"packages": {"": {"dependencies": {- "@playwright/test": "^1.60.0-alpha-2026-04-06"+ "@playwright/test": "^1.60.0-alpha-2026-04-13"}},"node_modules/@playwright/test": {- "version": "1.60.0-alpha-2026-04-06",- "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0-alpha-2026-04-06.tgz",- "integrity": "sha512-RtA98sOfvb6hVi4sV9WjPb6MRgND8GQv0EeqKWUarjxcMnbU3DE0W1HHVjd6PZInJuuIz2gxy7KnQaH+mtyjaw==",+ "version": "1.60.0-alpha-2026-04-13",+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0-alpha-2026-04-13.tgz",+ "integrity": "sha512-J4VCqMkEfLvhjnkq5MJ71tA7dk+1eTl3HN4UiCGQuvK0rPxrJo2dth1k7wgpHCc5IPbWtwrZ22kE7B/dcW6Gmw==","license": "Apache-2.0","dependencies": {- "playwright": "1.60.0-alpha-2026-04-06"+ "playwright": "1.60.0-alpha-2026-04-13"},"bin": {"playwright": "cli.js"@@ -38,12 +38,12 @@}},"node_modules/playwright": {- "version": "1.60.0-alpha-2026-04-06",- "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0-alpha-2026-04-06.tgz",- "integrity": "sha512-XYIVJkx10/bo+JXcuTIMxsvH1aA5Ue/ITGnp8oVNWCbYJIyyGSyUmo3dPrF2mRqiuUEripnXs0Apblfm9zZCxA==",+ "version": "1.60.0-alpha-2026-04-13",+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0-alpha-2026-04-13.tgz",+ "integrity": "sha512-BeFO7QP7SByPXrvEKRxdMrTZyvs3lAcyYdiwpBNspu40Du+xVrkd+QMZ+uCpal+0/sLxhba4Js8lwgnq9g+2VQ==","license": "Apache-2.0","dependencies": {- "playwright-core": "1.60.0-alpha-2026-04-06"+ "playwright-core": "1.60.0-alpha-2026-04-13"},"bin": {"playwright": "cli.js"@@ -56,9 +56,9 @@}},"node_modules/playwright-core": {- "version": "1.60.0-alpha-2026-04-06",- "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0-alpha-2026-04-06.tgz",- "integrity": "sha512-iBJKirdBcH9mGKRjLG4sT05cKixhWO0EMFK6jpRZT6EflUf7ucPDB0lZo+SJfDuq6VIDIvjh0J4o9V81qkQUvQ==",+ "version": "1.60.0-alpha-2026-04-13",+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0-alpha-2026-04-13.tgz",+ "integrity": "sha512-MPqII482p7ujGxf3kMdAuX78VdDAoRZrzW/CX0/zq/bVh/IfPeTOZ3eHUk/jeFp1dQLCFyWiiL0hcthDX1fQBA==","license": "Apache-2.0","bin": {"playwright-core": "cli.js"diff --git a/tests/playwright-test/stable-test-runner/package.json b/tests/playwright-test/stable-test-runner/package.jsonindex 5bd89e2dab..1470ee6a02 100644--- a/tests/playwright-test/stable-test-runner/package.json+++ b/tests/playwright-test/stable-test-runner/package.json@@ -1,6 +1,6 @@{"private": true,"dependencies": {- "@playwright/test": "^1.60.0-alpha-2026-04-06"+ "@playwright/test": "^1.60.0-alpha-2026-04-13"}}diff --git a/tests/playwright-test/test-server.spec.ts b/tests/playwright-test/test-server.spec.tsindex 8fe901ac69..e5cc1c31b2 100644--- a/tests/playwright-test/test-server.spec.ts+++ b/tests/playwright-test/test-server.spec.ts@@ -17,7 +17,7 @@// @ts-nocheckimport { test as baseTest, expect } from './ui-mode-fixtures';-import { TestServerConnection } from '../../packages/playwright/lib/runner';+import { TestServerConnection } from '../../packages/playwright/lib/isomorphic';import { playwrightCtConfigText } from './playwright-test-fixtures';import ws from 'ws';import type { TestChildProcess } from '../config/commonFixtures';diff --git a/utils/build/build.js b/utils/build/build.jsindex 227063722d..a4b5ae0770 100644--- a/utils/build/build.js+++ b/utils/build/build.js@@ -781,6 +781,19 @@ steps.push(new EsbuildStep({plugins: [dynamicImportToRequirePlugin],}, [filePath('packages/playwright/src')]));+// playwright/lib/isomorphic/index.js — bundled isomorphic barrel.+steps.push(new EsbuildStep({+ bundle: true,+ entryPoints: [filePath('packages/playwright/src/isomorphic/index.ts')],+ outfile: filePath('packages/playwright/lib/isomorphic.js'),+ sourcemap: withSourceMaps ? 'linked' : false,+ platform: 'node',+ format: 'cjs',+ external: [+ ],+ plugins: [dynamicImportToRequirePlugin],+}, [filePath('packages/playwright/src')]));+// playwright/lib/loader/loaderProcessEntry.js — bundled loader process// entry. Output sits at the same depth as the source so '../X' externals// resolve to lib/X.js naturally.