Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

test_runner: change-aware test selection

Offen
#66,006 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
45/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, node.js
Bereich
cli, testing

Rechercherichtung

Beginne mit dem Einstiegspunkt node --test, der bestehenden Implementierung von --watch und run({ files }); verfolge anschließend den vom Testrunner verwendeten Resolver. Als erledigt gilt die Auswahl von Tests anhand statischer Modulabhängigkeiten, während Tests mit opaken Abhängigkeiten oder globalen Paketänderungen konservativ ausgeführt werden, mit Testabdeckung für die genannten CJS- und Fälle mit unsichtbaren Abhängigkeiten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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 dynamic import(), 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

Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.4k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
277

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus nodejs/node

Alle Issues in nodejs/node

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.