test_runner: change-aware test selection
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 45/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js
研究方向
從 node --test 入口點、現有的 --watch 實作和 run({ files }) 開始;接著追蹤測試執行器使用的 resolver。完成標準是透過靜態模組相依性選取測試,同時對具有不透明相依性或全域套件變更的測試採取保守的執行方式,並涵蓋所述的 CJS 和不可見相依性案例。
由索引模型根據 Issue 內容生成。
描述
What is the problem this feature will solve?
node --test always runs every test file. There is no way to run only the tests affected by a change.
--watch does this, but only while it stays running. CI, a pre-commit hook, or a branch diff all start cold and run everything.
Jest (--onlyChanged) and Vitest (--changed) both do this.
What is the feature you are proposing to solve the problem?
Run only the test files whose module graph reaches a given set of files.
$ node --test --related=src/util.ts # tests that depend on a file
$ git diff --name-only | node --test --related=- # tests affected by a change
Graph-aware, not path-based: a test that imports a module that imports the changed file is selected. Conservative by default, so anything the graph cannot see has to run, and a change to package.json or a lockfile disables filtering entirely.
Paths rather than a --changed=<rev> flag, because that would mean core shelling out to git. There is no VCS dependency anywhere in lib/ today and I don't think this justifies introducing one. --changed can be layered on later if the team wants it.
Things to figure out
- CJS. Static imports can be extracted from an ES module without executing it. There is no equivalent for
require(), since the bundled lexer reports exports rather than requires. CJS files would be opaque: any test reaching one always runs. Correct, but a CJS-heavy project gets little out of this. - Invisible dependencies. A test that reads a fixture with
fs, or uses dynamicimport(), cannot be selected statically. Those have to resolve to "run it".
Under-selection is the failure mode that matters. Silently skipping a test the change broke is worse than not having the feature.
What alternatives have you considered?
Userland: a wrapper computing the list and passing it to run({ files }). Every such tool has to reimplement module resolution, and gets TypeScript, subpath imports and node_modules boundaries subtly wrong. The resolver is already in core.
--test-rerun-failures covers rerunning what failed, not running what a change could break.
cc @nodejs/test_runner
- 主要語言
- JavaScript
- 星號
- 122k
- 分支
- 38.4k
- 平均合併
- 3 天 22 小時
- 30 天內合併 PR
- 273
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`可能已有人在做 @lazerg 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
build / doc: missing platform and toolchain info for `linux-x64-musl`可能已有人在做 @theSnackOverflow 於 1 天前認領。 未關閉alpine build doc
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 於 10 天前認領。 未關閉doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 於 11 天前認領。 未關閉doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
build
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
相似的 Issue
-
macOS
難度 2/5 1-3 小時 新手友好度 76/100
beyondcode/herd-community#1761 ·
-
content good first issue hacktoberfest
難度 2/5 1-3 小時 新手友好度 74/100
vieanderes/understory#19 ·
-
automated issue report
難度 2/5 1-3 小時 新手友好度 68/100
lirantal/discoprint#37 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
tauri-apps/tauri#16219 ·
維護者通常 2 天內回覆
-
agentic-workflows
難度 1/5 1 小時以內 新手友好度 90/100
githubnext/gh-aw-cao#16599 ·
維護者通常 1 天內回覆