Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

unit-test builder (Vitest): key `fsModuleCache` on the served build output instead of forcing it off

Ouverte
#34,443 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@jv3n y travaille déjà.

Depuis le 20/10/2026.

  • #34444 par @jv3n — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
20/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
angular, typescript

Piste de recherche

Start in the angular:test-in-memory-provider plugin’s configureVitest hook and inspect how buildResultFiles are served and hashed. Check the unit-test builder configuration that forces fsModuleCache off, then trace how the cache key can include the served output and source map hashes. Done means the cache can be enabled without stale results when an imported file changes; the issue reports a fix-ready linked pull request, #34444.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area: @angular/build
Command

test

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

Since f0a74e8f0 (released in 22.2.3), @angular/build:unit-test forces fsModuleCache: false, at the root and on the test project, overriding the runnerConfig. The reason is sound: Vitest keys its file system module cache on the file found on disk, while a test entry point is served from its bundle, which also holds the application code the spec imports. Changing an imported file without touching the spec left the key unchanged, and the cache served a stale bundle.

Vitest provides a hook for exactly this case: a plugin can add its own part to the cache key with defineCacheKeyGenerator, from configureVitest. The angular:test-in-memory-provider plugin already implements configureVitest and holds buildResultFiles, the files its load() serves, each with a content hash. Keying the cache on the served build output (the output file hash plus its source map hash) removes the staleness at its root, so the cache does not need to be turned off.

Since #34337 (also in 22.2.3) the test bundles are byte-identical from one build to the next, so such a key is stable and the cache can be reused across runs and CI pipelines.

Measured on a workspace application with 255 spec files (warm Angular cache, macOS, runs alternated on an idle machine), the builder patched as described:

builder Vitest duration ng test wall time
22.2.3 (cache forced off) 21.4 s, 21.4 s 36.6 s, 37.9 s
patched, warm fsModuleCache 20.0 s, 18.4 s 35.8 s, 35.8 s

The gain is modest here, since execution dominates this suite; it grows with the share of transform time. On the same workspace, changing a file imported by a spec (without touching the spec) makes that spec fail as expected, and reverting the change reuses the original cache entry.

I have a fix ready and will open a PR referencing this issue.

Minimal Reproduction
  1. In a project using @angular/build:unit-test with Vitest 5, set fsModuleCache: true and fsModuleCachePath: './.vitest-cache' in the runnerConfig.
  2. Run ng test --no-watch.
  3. No .vitest-cache directory is created: the builder overrides the option.
Exception or Error

No response

Your Environment
Angular CLI       : 22.2.3
Angular           : 22.2.3
Node.js           : 24.21.0
Package Manager   : npm 11.19.0
Operating System  : darwin arm64

@angular/build    : 22.2.3
vitest            : 5.0.4
Anything else relevant?

Follow-up of #34335 / #34337 (deterministic test discovery) and of f0a74e8f0 (fsModuleCache disabled to avoid stale bundles).

Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
1 j 5 h
PR mergées (30 j)
244

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de angular/angular-cli

Toutes les issues de angular/angular-cli

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.