-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Version
1.58.0
Steps to reproduce
Minimal Reproduction Repository: https://github.com/Abhinegi2/playwright-issue
Clone the repository and run:
git clone https://github.com/Abhinegi2/playwright-issue.git
cd playwright-issue
npm install
npx playwright install chromium
npx playwright testOr reproduce from scratch:
- Create a TypeScript ESM project with "type": "module" in package.json.
- Install @playwright/[email protected] and [email protected]
- import tsx/esm in [playwright.config.ts]
import { defineConfig } from "@playwright/test";
import "tsx/esm";
export default defineConfig({
testDir: "./tests",
build: { external: ["*"] },
});
- Create any test file (e.g., tests/example.spec.ts)
- Run npx playwright test
Expected behavior
Playwright should only collect and execute tests from *.spec.ts files (or other configured test file patterns). No *.esm.preflight files should be involved in test collection.
Actual behavior
Playwright reports duplicate test title errors, referencing non-existent *.esm.preflight files:
Error: duplicate test title "example test", first declared in example.spec.ts.esm.preflight:3
at example.spec.ts:1
1 | import { test, expect } from "@playwright/test";
| ^
2 |
3 | test("example test", async ({ page }) => {
4 | await page.goto("[https://example.com](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html)");
These .esm.preflight files don't exist in the repository but appear to be created by the tsx/esm loader and are being incorrectly collected as test files by Playwright.
Additional context
- Regression: This works correctly in Playwright 1.57.0
- Workaround: Downgrade to
@playwright/[email protected] - Real-world impact: This is blocking upgrades in production projects, such as Aam-Digital/ndb-core
- Related issue: [Bug]: Playwright 1.58.0 collects *.esm.preflight files as tests, causing duplicate test title errors #39028 (closed, requesting proper repro - this is the proper reproduction)
The .esm.preflight files appear to be generated by tsx's ESM loader transformation but should be excluded from Playwright's test file collection pattern.
Environment
System:
OS: macOS 26.2
CPU: (8) arm64 Apple M3
Memory: 92.39 MB / 8.00 GB
Binaries:
Node: 22.19.0
npm: 11.6.4
IDEs:
VSCode: 1.108.2
Languages:
Bash: 3.2.57
npmPackages:
@playwright/test: 1.58.0