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

オープン
#43,824 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@microsoft-playwright-automation がすでに取り組んでいます。

2026年11月1日 から。

  • #43825 @cpeaustriajc による — マージされずにクローズ
  • #43837 @microsoft-playwright-automation による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
nodejs, typescript
領域
testing

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
99.1k
フォーク
6.8k
平均マージ
16時間 3分
マージ済み PR(30日)
315

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/playwright のほかの issue

microsoft/playwright の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。