fix(@angular/build): trigger test re-run on non-spec file changes in watch mode#32884
Open
maruthang wants to merge 1 commit intoangular:mainfrom
Open
fix(@angular/build): trigger test re-run on non-spec file changes in watch mode#32884maruthang wants to merge 1 commit intoangular:mainfrom
maruthang wants to merge 1 commit intoangular:mainfrom
Conversation
…watch mode When non-test files (services, components, etc.) change during watch mode, use Vitest's module graph to find dependent test specifications and include them in the re-run set. Previously only direct .spec.ts file changes triggered test re-runs. Consolidates the file processing into a single loop for clarity. Fixes angular#32159
There was a problem hiding this comment.
Code Review
This pull request enhances the Vitest test runner to ensure that changes to non-test files, such as components or services, correctly trigger test reruns in watch mode. The implementation now utilizes Vitest's module graph to identify and queue dependent test specifications when an output file is modified. Additionally, a new behavior test has been added to verify that modifying a component file results in the expected test execution and results. I have no feedback to provide as there were no review comments to evaluate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
In watch mode, the unit-test builder only re-runs tests when
.spec.tsfiles change. Changes to non-test files (services, components, etc.) are ignored becauseentryPointToTestFileonly maps test files, andgetModuleSpecifications()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?