Repository navigation
Conversation
alan-agius4
reviewed
Oct 13, 2026
There was a problem hiding this comment.
Code Review
This pull request updates the findTests function to sort the resolved test files, ensuring deterministic build outputs regardless of the asynchronous directory crawling order. A new unit test suite has also been added to verify this sorting behavior. The review feedback suggests providing an explicit, locale-independent comparison function to Array.prototype.sort() to avoid potential linting errors and guarantee strict determinism across different environments.
jv3n
force-pushed
the
fix/unit-test-deterministic-test-order
branch
from
October 13, 2026 17:30
7af73a2 to
72f963a
Compare
alan-agius4
approved these changes
Oct 14, 2026
1 task
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?
Issue Number: #34335
findTestsreturns the test files in the ordertinyglobbyyields them. The glob crawls directories asynchronously, so the order changes between runs: on a project with 255 spec files, 8 consecutive calls returned 8 different orders (same set of files). That order feeds the build entry points androotFiles, so twong testbuilds of the same sources produce different chunks: imports come out reordered, the content-hashed chunk names change, and the change cascades to every importer (79 to 89 of 593 output files renamed between two runs). This defeats Vitest 5'sfsModuleCache, which is keyed on file content.What is the new behavior?
The discovered test files are sorted before being turned into entry points. With that change, three consecutive builds of the same project produced byte-identical test bundles (0 of 593 files differing,
--dump-virtual-filesoutput compared withdiff -r), and Vitest's module cache was fully reused across runs.A
findTestsspec checks the result is sorted. The crawl order can happen to be sorted on a small fixture, so it guards against a regression rather than reproducing the race on every run.Does this PR introduce a breaking change?
Other information
Measured with
@angular/build22.2.2, Vitest 5.0.4, Node 24, on macOS; the same non-determinism shows up in AOT and JIT test builds, with and without--coverage, and withNG_BUILD_MAX_WORKERS=1.