ng-add support for Vitest browser providers doesn't work
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- angular, playwright, typescript
- Área
- build-system, cli, testing-qa
Línea de trabajo
Reproduce el problema con los pasos indicados de ng new, ng add, instalación de Playwright y ng test. Compare los angular.json y tsconfig.spec.json generados con la configuración documentada del modo de navegador y, después, inspeccione la compatibilidad con ng-add introducida por el commit f80db6f. Se considera terminado cuando ng add configura la opción browsers para que ng test se ejecute en el entorno de navegador de Vitest en lugar de jsdom en Node.js.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Command
add
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
@angular/cli v21.2.0-next.0 added in https://github.com/angular/angular-cli/commit/f80db6fb714aa326f6ed03a8a51090ca59ad0955 add ng-add support for Vitest browser providers but it is not complete and does not actually work.
The schematic correctly adds the required packages and modifies tsconfig.spec.json but does not add the browsers option as documented at https://angular.dev/guide/testing/migrating-to-vitest#5-configure-browser-mode-optional.
Without this option the test doesn't actually run in browser environment and is still run in DOM emulation library within Node.js.
Minimal Reproduction
Repro steps:
ng new angular22dot2dot0next0 --ssr=false --style=scss --ai-config=noneng add @vitest/browser-playwrightnpx playwright install- Open
app.spec.tsand add line to any test:console.log('RUNNING IN:', navigator.userAgent); - Run test via
ng test - Observe the console outputs:
RUNNING IN: Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/27.4.0 - Test still runs in Node.js with DOM emulation, not in Vitest browser ❌
How to fix:
- Open
angular.jsonand change:
"test": {
"builder": "@angular/build:unit-test"
}
to:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"browsers": ["chromium"]
}
}
- Run test via
ng test - Observe actual Chrome for Testing window opens and Console outputs:
RUNNING IN: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 - Test runs in Vitest browser 👍
Exception or Error
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 21.2.0-next.0
Node.js : 24.13.0
Package Manager : npm 11.6.2
Operating System : win32 x64
Anything else relevant?
No response
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 16 h 21 min
- PR fusionados (30 d)
- 170
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de angular/angular-cli
-
area: @angular/build gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
angular/angular-cli#34129 ·
-
Support aube as package manager Abiertoarea: @angular/cli gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
angular/angular-cli#34057 ·
-
Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-server Abiertoarea: @angular/build gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
angular/angular-cli#33055 · 1 comentario · 3 reacciones ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 asignado ·