Skip to content

[Bug]: Playwright 1.58.0 collects *.esm.preflight files as tests, causing duplicate test title errors #39172

@Abhinegi2

Description

@Abhinegi2

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 test

Or reproduce from scratch:

  1. Create a TypeScript ESM project with "type": "module" in package.json.
  2. Install @playwright/[email protected] and [email protected]
  3. import tsx/esm in [playwright.config.ts]
import { defineConfig } from "@playwright/test";
import "tsx/esm";
export default defineConfig({
testDir: "./tests",
build: { external: ["*"] },
}); 
  1. Create any test file (e.g., tests/example.spec.ts)
  2. 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions