[Bug]: --only-changed misses a test file when two ESM test files share an import

Aperta
#43,824 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cpeaustriajc ci sta già lavorando.

Dal 31/10/2026.

  • #43825 di @cpeaustriajc — aperta
  • #43837 di @microsoft-playwright-automation — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
nodejs, typescript
Ambito
testing

Direzione di ricerca

Start with the ESM loader hooks in esmLoaderSync.ts and esmLoader.ts, where the resolve hook records dependencies, and compare them with collectCJSDependencies, which walks module.children. Check stopCollectingFileDeps and the --only-changed path. Pull request #43825 is already open against this issue, so review that work or the reproduction in tests/playwright-test/only-changed.spec.ts rather than starting a parallel fix. Done means both spec files are listed when a shared leaf changes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage
Version

1.63.0, 1.64.1 and current main

Steps to reproduce
  1. Make a project with "type": "module" in package.json.
  2. Make a.spec.ts and b.spec.ts. Both import shared.ts, and shared.ts imports leaf.ts.
  3. Commit, then change leaf.ts.
  4. Run npx playwright test --only-changed --list.
Expected behavior

Both a.spec.ts and b.spec.ts are listed.

Actual behavior

Only the test file that loads shared.ts first is listed.

Additional context

In ESM mode, Playwright records dependencies in the loader's resolve hook (esmLoaderSync.ts and esmLoader.ts). Node calls resolve only when it first links a module. So the imports of shared.ts go only to the first test file that loads it. The CommonJS path (collectCJSDependencies) walks module.children and does not have this problem.

I have a fix ready. The resolve hook records each parent-to-child import edge, and stopCollectingFileDeps closes each test file's dependency set over those edges. A new test in tests/playwright-test/only-changed.spec.ts, "should understand dependency structure shared between esm test files", fails without the fix and passes with it. I can open a PR if you want it.

Environment

Node 26.12.1, macOS

Lingua principale
TypeScript
Stelle
99.1k
Fork
6.8k
Merge medio
16h 3m
PR unite (30g)
315

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.