fix(@angular/build): trigger test re-run on non-spec file changes in watch mode by maruthang · Pull Request #32884 · angular/angular-cli
PR Checklist
- The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-commit-message-guidelines
- Tests for the changes have been added (for bug fixes / features)
- Docs have been added / updated (for bug fixes / features)
PR Type
- Bugfix
What is the current behavior?
In watch mode, the unit-test builder only re-runs tests when .spec.ts files change. Changes to non-test files (services, components, etc.) are ignored because entryPointToTestFile only maps test files, and getModuleSpecifications() is never called for unmapped files.
Issue Number: #32159
What is the new behavior?
When non-test files change during watch mode, vitest.getModuleSpecifications() is called on the absolute output file path. Vitest's module graph traverses backwards to find all dependent test specifications, which are then included in the re-run set.
The file processing has been consolidated into a single loop for clarity — test files are mapped via entryPointToTestFile, non-test files query Vitest's module graph directly.
Does this PR introduce a breaking change?
- Yes
- No