From 1257bee94725bb8cb2c654235995f1d5e667bf7e Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 11 May 2026 11:14:12 -0700 Subject: [PATCH 1/3] fix(test-runner): match absolute file paths containing spaces on Windows Fixes: https://github.com/microsoft/playwright/issues/40767 --- packages/playwright/src/util.ts | 7 +++---- .../command-line-filter.spec.ts | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index 7941dd731f118..ce7da5ef8bcc4 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -16,7 +16,6 @@ import fs from 'fs'; import path from 'path'; -import url from 'url'; import util from 'util'; import debug from 'debug'; @@ -114,12 +113,12 @@ export function createFileMatcher(patterns: string | RegExp | (string | RegExp)[ return true; } // Windows might still receive unix style paths from Cygwin or Git Bash. - // Check against the file url as well. + // Check against the forward-slash form as well. if (path.sep === '\\') { - const fileURL = url.pathToFileURL(filePath).href; + const unixPath = filePath.split(path.sep).join('/'); for (const re of reList) { re.lastIndex = 0; - if (re.test(fileURL)) + if (re.test(unixPath)) return true; } } diff --git a/tests/playwright-test/command-line-filter.spec.ts b/tests/playwright-test/command-line-filter.spec.ts index e33cb8b318063..65c9df3cd6fd3 100644 --- a/tests/playwright-test/command-line-filter.spec.ts +++ b/tests/playwright-test/command-line-filter.spec.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import path from 'path'; + import { test, expect } from './playwright-test-fixtures'; test('should filter by file name', async ({ runInlineTest }) => { @@ -172,6 +174,24 @@ test('should focus a single nested test spec', async ({ runInlineTest }) => { expect(result.report.suites[1].suites[0].suites[0].specs[0].title).toEqual('pass2'); }); +test('should accept absolute file path containing a space', async ({ runInlineTest }, testInfo) => { + const absolutePath = path.join(testInfo.outputPath(), 'dir with space', 'a.spec.ts').split(path.sep).join('/'); + const result = await runInlineTest({ + 'dir with space/a.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('passes', () => { expect(1).toBe(1); }); + `, + 'dir with space/b.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('not picked', () => { expect(1).toBe(2); }); + `, + }, undefined, undefined, { additionalArgs: [absolutePath] }); + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); + expect(result.report.suites).toHaveLength(1); + expect(result.report.suites[0].specs[0].title).toBe('passes'); +}); + test('should focus a single test suite', async ({ runInlineTest }) => { const result = await runInlineTest({ 'foo.test.ts': ` From fe35ae048e7e623f7ed8de3e0b7e99b087ab686d Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 11 May 2026 11:50:57 -0700 Subject: [PATCH 2/3] test(test-runner): use unix-style relative path in spaces filter test --- tests/playwright-test/command-line-filter.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/playwright-test/command-line-filter.spec.ts b/tests/playwright-test/command-line-filter.spec.ts index 65c9df3cd6fd3..7eb17f8193fb6 100644 --- a/tests/playwright-test/command-line-filter.spec.ts +++ b/tests/playwright-test/command-line-filter.spec.ts @@ -174,8 +174,7 @@ test('should focus a single nested test spec', async ({ runInlineTest }) => { expect(result.report.suites[1].suites[0].suites[0].specs[0].title).toEqual('pass2'); }); -test('should accept absolute file path containing a space', async ({ runInlineTest }, testInfo) => { - const absolutePath = path.join(testInfo.outputPath(), 'dir with space', 'a.spec.ts').split(path.sep).join('/'); +test('should accept unix file path containing a space', async ({ runInlineTest }) => { const result = await runInlineTest({ 'dir with space/a.spec.ts': ` import { test, expect } from '@playwright/test'; @@ -185,7 +184,7 @@ test('should accept absolute file path containing a space', async ({ runInlineTe import { test, expect } from '@playwright/test'; test('not picked', () => { expect(1).toBe(2); }); `, - }, undefined, undefined, { additionalArgs: [absolutePath] }); + }, undefined, undefined, { additionalArgs: ['dir with space/a.spec.ts'] }); expect(result.exitCode).toBe(0); expect(result.passed).toBe(1); expect(result.report.suites).toHaveLength(1); From 8bdde55cdffcb913b149a75a6558d2fa640bbea3 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 11 May 2026 11:51:26 -0700 Subject: [PATCH 3/3] chore: drop unused path import --- tests/playwright-test/command-line-filter.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/playwright-test/command-line-filter.spec.ts b/tests/playwright-test/command-line-filter.spec.ts index 7eb17f8193fb6..7d9ee14294a8d 100644 --- a/tests/playwright-test/command-line-filter.spec.ts +++ b/tests/playwright-test/command-line-filter.spec.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import path from 'path'; - import { test, expect } from './playwright-test-fixtures'; test('should filter by file name', async ({ runInlineTest }) => {