Skip to content

fix(@angular/build): warn when TestBed.overrideComponent is used in AOT mode#33542

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-aot-override-warning
Open

fix(@angular/build): warn when TestBed.overrideComponent is used in AOT mode#33542
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-aot-override-warning

Conversation

@clydin

@clydin clydin commented Jul 9, 2026

Copy link
Copy Markdown
Member

TestBed.overrideComponent is a JIT-first API that relies on runtime decorator metadata to dynamically recompile components. When tests are compiled in AOT mode (which is the default for vitest and some karma configurations), decorator metadata is compiled away, meaning template or imports overrides can fail silently or cause confusing NG0304/NG0303 errors.

To improve developer experience, this adds a runtime warning when TestBed.overrideComponent is called on an AOT-compiled component in AOT mode. A warning is printed to the console suggesting to disable AOT (aot: false) in the test build configuration as a workaround.

…OT mode

TestBed.overrideComponent is a JIT-first API that relies on runtime decorator metadata to dynamically recompile components. When tests are compiled in AOT mode (which is the default for vitest and some karma configurations), decorator metadata is compiled away, meaning template or imports overrides can fail silently or cause confusing NG0304/NG0303 errors.

To improve developer experience, this adds a runtime warning when TestBed.overrideComponent is called on an AOT-compiled component in AOT mode. A warning is printed to the console suggesting to disable AOT (aot: false) in the test build configuration as a workaround.
@clydin clydin added the target: patch This PR is targeted for the next patch release label Jul 9, 2026
@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant