-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
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
When running tests through the Angular CLI with Vitest, watch and coverage options defined in vitest.config.ts are silently overridden by default settings from angular.json.
angular.json:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"runner": "vitest",
"runnerConfig": "vitest.config.ts"
}
}vitest.config.ts:
export default defineConfig({
test: {
watch: false,
reporters: [
'default',
['junit', { outputFile: "tmp/test-results/junit.xml" }]
],
coverage: {
enabled: true,
reportsDirectory: "tmp/coverage",
reporter: ['cobertura', 'lcov'],
}
}
});Expected behaviour
Either:
-
The CLI should respect the values defined in
vitest.config.tsfor options such aswatchandcoverage, or -
The documentation should clearly list all options that Angular CLI overrides (atm it only states that 'The CLI will also override certain properties (test.projects, test.include) to ensure proper operation.').
It is difficult to reason about which configuration source has precedence. Especially when coverage and watch flags aren't even configured in angular.json and their default values are used.
Minimal Reproduction
Repro repo: https://github.com/ArturMroz/vitest-flags-repro
- Create and configure
vitest.config.tsandangular.json(already done in the repo) - Run
ng test - Observe: watch mode is enabled and no coverage is created
Exception or Error
Your Environment
Angular CLI : 21.2.2
Angular : 21.2.4
Node.js : 22.18.0
Package Manager : npm 10.9.3
Operating System : win32 x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.2.2 │ ^21.2.2 │
│ @angular/cli │ 21.2.2 │ ^21.2.2 │
│ @angular/common │ 21.2.4 │ ^21.2.0 │
│ @angular/compiler │ 21.2.4 │ ^21.2.0 │
│ @angular/compiler-cli │ 21.2.4 │ ^21.2.0 │
│ @angular/core │ 21.2.4 │ ^21.2.0 │
│ @angular/forms │ 21.2.4 │ ^21.2.0 │
│ @angular/platform-browser │ 21.2.4 │ ^21.2.0 │
│ @angular/router │ 21.2.4 │ ^21.2.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
│ vitest │ 4.1.0 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response