TestBed.overrideComponent doesn't work with AOT and webpack
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- angular, typescript
- Ambito
- build-system, testing-qa
Direzione di ricerca
Inizia con la riproduzione minima: un test del componente che utilizzi TestBed.overrideComponent o TestBed.overrideModule con Karma, il webpack builder in browser mode e AOT abilitato. Confronta l’errore con application builder mode o con AOT disabilitato, quindi verifica che il test di override venga eseguito senza l’errore relativo ai metadati @Component mancanti nella configurazione interessata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
TestBed.overrideComponent and TestBed.overrideModule don't seem to work with karma, webpack builder (builderMode: browser) and aot enabled. Changing any of these settings, so builderMode: application or disabling aot "fixes" the problem. The same issue was reported here https://github.com/angular/angular-cli/issues/30017 but i guess it was only fixed for esbuild? Is there any workaround for this? or can it be fixed for angular20?
Minimal Reproduction
Create a simple valid component, turn on AOT for Karma, and make a test where you use TestBed.overrideComponent to reset metadata. You don't even need to specify an actual override in the second parameter to trigger the issue: TestBed.overrideComponent(YourComponent, {}) triggers the failure.
builderMode: browser needs to be set
Exception or Error
Error: App class doesn't have @Component decorator or is missing metadata.
at invalidTypeError (node_modules/@angular/core/fesm2022/testing.mjs:1661:12)
at forEach (node_modules/@angular/core/fesm2022/testing.mjs:1084:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:1)
at apply (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:17:1)
at _ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:398:28)
at ProxyZoneSpec.onInvoke (node_modules/zone.js/fesm2015/zone-testing.js:2132:39)
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 20.3.18
Node: 22.22.0
Package Manager: npm 10.9.4
OS: win32 x64
Angular: 20.3.17
... common, compiler, compiler-cli, core, forms
... platform-browser, router
Package Version
---------------------------------------
@angular-devkit/architect 0.2003.18
@angular-devkit/build-angular 20.3.16
@angular-devkit/core 20.3.18
@angular-devkit/schematics 20.3.18
@angular/build 20.3.18
@angular/cli 20.3.18
@schematics/angular 20.3.18
rxjs 7.8.2
typescript 5.9.3
zone.js 0.15.1
Anything else relevant?
No response
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 16h 21m
- PR unite (30g)
- 170
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular-cli
-
area: @angular/build gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
angular/angular-cli#34129 ·
-
area: @angular/cli gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
angular/angular-cli#34057 ·
-
area: @angular/build gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/angular-cli#33055 · 1 commento · 3 reazioni ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 assegnatario ·
Tutte le issue di angular/angular-cli
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Add: Star Sports 2 Telugu HD Apertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100