Repository navigation
fix(git-diff): run every test when only babel.config changes - #108
adityankale190895 merged 3 commits into
Conversation
babel-jest transforms every test file with babel.config.*, but a .js, .cjs, .mjs or .ts babel.config is a code file that nothing imports, so a change to it alone was classified as source with no dependents and the plan was SELECTIVE with zero tests. Treat babel.config.* as configuration, like jest.config.*, so it falls back to a full run. Adds a Jest + babel-jest fixture that changes only babel.config.* (four extensions) or only .babelrc and asserts a full run. Fixes DiffCI#99 Signed-off-by: sarankumar1325 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf448027a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /^jest\.config\./, | ||
| // babel-jest transforms every test file with it; without this a .js/.ts babel.config was classified as | ||
| // source with no importers and selected no tests (2026-11-11, #99). | ||
| /^babel\.config\./, |
There was a problem hiding this comment.
Add
.babelrc.* variants to the global fallback
When a Jest project uses a JavaScript-style Babel config such as .babelrc.js or .babelrc.cjs and only that file changes, this pattern still misses it. isConfigFile likewise recognizes only babel.config*, so the file remains source code and an unimported config can produce a selective plan with no tests selected or fallback required, even though Babel applies it while transforming tests. The existing .babelrc.* implicit-load handling in file-references.ts confirms these files are treated as runtime-loaded configs; include them in the global config handling too.
Useful? React with 👍 / 👎.
|
Thanks @sarankumar1325, this is a real fix: the before/after table makes the unsafe One thing before this one lands: the Codex comment above is right.
plus Separately, and not for this PR: a |
.babelrc.js, .babelrc.cjs and .babelrc.mjs are code files that nothing imports, so a change to only one of them still selected no tests. The config pattern and isConfigFile now cover every .babelrc form. Signed-off-by: sarankumar1325 <[email protected]>
Signed-off-by: sarankumar1325 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]>
Fixes #99
What DiffCI did before this PR
I built the fixture the issue asks for: a Jest project that uses babel-jest, with two source files, two tests and a Babel config. The head commit changes only the Babel config. Then I ran
analyzeCheckouton it..babelrcbabel.config.js/.cjs/.mjs/.tsbabel.config.json.babelrc.js/.cjs/.mjsThe
babel.config.{js,cjs,mjs,ts}and.babelrc.{js,cjs,mjs}cases were not safe. babel-jest transforms every test with that config, but the file is a code file that nothing imports. So it was classified assourcewith no dependents, and the plan skipped every test with no fallback reason..babelrcwas safe, but only through the generic unknown-file fallback.Fix
babel.config.*is now configuration, likejest.config.*:CONFIG_PATTERNSinsrc/git/git-diff.tsgets/^(?:babel\.config\.|\.babelrc)/, soconfigChangedtriggers the existingCONFIG_GLOBALfull fallback.isConfigFileinsrc/repo/impact.tsclassifiesbabel.config*and.babelrc*asconfiginstead ofsource..babelrc.*was added in 3f5a6dc after the Codex review.babel.configwas already listed as implicitly loaded infile-references.ts, so reference resolution was skipped. But nothing turned that into a fallback for code-file extensions.Tests
tests/repo/babel-config-change.test.ts. It builds a temporary git repository for each case and runsanalyzeCheckout. It checks that a change to onlybabel.config.{js,cjs,mjs,ts},.babelrc.{js,cjs,mjs,json}or.babelrcgives mode FULL,fallbackRequired, both tests selected, nothing skipped, and a fallback reason that names the file. Without the source change, thebabel.config.*and.babelrc.{js,cjs,mjs}cases fail. The.babelrcand.babelrc.jsoncases pass either way.tests/repo/config-patterns.test.ts: added thebabel.config.jsexample for the new entry.release-files.json.npm test: 909 passed.npm run typecheckis clean, and so arenpm run buildandnpm run audit:boundary.Not covered: a
babel.config.*in a subdirectory.CONFIG_PATTERNSmatches only at the root, the same asjest.config.*.