Repository navigation
fix(@angular/build): disable Vitest fsModuleCache in unit-test builder - #34311
Merged
alan-agius4 merged 1 commit intoOct 12, 2026
Merged
Conversation
Vitest 5.0.4 enabled `fsModuleCache` by default, which caches transformed modules on disk keyed by the raw source file content on disk before calling Vite's `load()` hook. Because `@angular/build:unit-test` pre-bundles test entry points and their imported application modules into memory, changes to imported application files do not change the on-disk `.spec.ts` file content, causing Vitest's `fsModuleCache` to serve stale cached bundles across test runs.
crisbeto
approved these changes
Oct 12, 2026
There was a problem hiding this comment.
Code Review
This pull request disables Vitest's fsModuleCache by setting it to false in the configuration plugin. A review comment points out that a user's explicit configuration in vitest.config.ts could override this setting due to Vite's config merging behavior, and suggests deleting the option from the user's configuration while warning them.
Collaborator
Author
FreekMencke
added a commit
to osrs-tracker/osrs-tracker-web
that referenced
this pull request
Oct 14, 2026
Vitest 5 caches transformed modules in node_modules/.vitest-cache, keyed by the spec file on disk, while Angular's unit-test builder hands it the spec bundled with the code under test. A change to that code alone reused the old bundle, so local runs (and verify.sh) could pass on stale code. CI installs fresh and was unaffected. A runnerConfig file sets fsModuleCache: false until @angular/build ships angular/angular-cli#34311 (merged after 22.2.2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FreekMencke
added a commit
to FreekMencke/freek-mencke-web
that referenced
this pull request
Oct 14, 2026
Ran `ng update @angular/cli --name migrate-karma-to-vitest`, which switches `ng test` to the unit-test builder with Vitest 5. Removed the Karma and Jasmine packages and their VS Code launch entry, and added jsdom. As in osrs-tracker-web, vitest-base.config.ts turns off Vitest 5's module cache, which reran a stale bundle after a change to the tested code alone (angular/angular-cli#34311, not released in 22.2.2). Adds a first spec (MenuButtonComponent) and runs `npm test` in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FreekMencke
added a commit
to FreekMencke/freek-mencke-web
that referenced
this pull request
Oct 14, 2026
* test: migrate from Karma to Vitest Ran `ng update @angular/cli --name migrate-karma-to-vitest`, which switches `ng test` to the unit-test builder with Vitest 5. Removed the Karma and Jasmine packages and their VS Code launch entry, and added jsdom. As in osrs-tracker-web, vitest-base.config.ts turns off Vitest 5's module cache, which reran a stale bundle after a change to the tested code alone (angular/angular-cli#34311, not released in 22.2.2). Adds a first spec (MenuButtonComponent) and runs `npm test` in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: align the Vitest setup with osrs-tracker-web Build the tests from `::development` instead of the migration's own `testing` configuration and leave `runner` and `tsConfig` at their defaults, run them in their own CI job, and remove the VS Code settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 17, 2026
FreekMencke
added a commit
to FreekMencke/freek-mencke-web
that referenced
this pull request
Oct 18, 2026
…he workaround (#26) @angular/build 22.2.3 turns fsModuleCache off itself (angular/angular-cli#34311), so vitest-base.config.ts, runnerConfig in angular.json and the knip entry go. Closes #19 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Vitest 5.0.4 enabled
fsModuleCacheby default, which caches transformed modules on disk keyed by the raw source file content on disk before calling Vite'sload()hook. Because@angular/build:unit-testpre-bundles test entry points and their imported application modules into memory, changes to imported application files do not change the on-disk.spec.tsfile content, causing Vitest'sfsModuleCacheto serve stale cached bundles across test runs.