You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 Karma in the new-to-19.2.x AOT mode, if you have any tests that use TestBed.overrideComponent() to specify different metadata to the component (an override to the providers property, for example), the test fails with an error about missing the @component decorator or having missing metadata. The error is thrown from invalidTypeError in test_bed_compiler.ts. As far as I could tell, the getAnnotation function in the resolver was returning null instead of Component, causing the error to be tripped. I assume the AOT build is stripping this metadata/the decorator before this check is made. I couldn't find any way to work around the issue other than rearchitecting my component so that I was no longer needing to make the overrideComponent call. As long as overrideComponent was in the stack at all, regardless of what parameters I passed to it, the tests failed due to missing metadata.
I have not tested any of the other types of overrides, but given that most of the code in the TestBed compiler is in common between the decorated types, I would assume they all are impacted in AOT mode.
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.
Exception or Error
_<class name> class doesn't have @Component decorator or is missing metadata.
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When running Karma in the new-to-19.2.x AOT mode, if you have any tests that use TestBed.overrideComponent() to specify different metadata to the component (an override to the providers property, for example), the test fails with an error about missing the @component decorator or having missing metadata. The error is thrown from invalidTypeError in test_bed_compiler.ts. As far as I could tell, the getAnnotation function in the resolver was returning null instead of Component, causing the error to be tripped. I assume the AOT build is stripping this metadata/the decorator before this check is made. I couldn't find any way to work around the issue other than rearchitecting my component so that I was no longer needing to make the overrideComponent call. As long as overrideComponent was in the stack at all, regardless of what parameters I passed to it, the tests failed due to missing metadata.
I have not tested any of the other types of overrides, but given that most of the code in the TestBed compiler is in common between the decorated types, I would assume they all are impacted in AOT mode.
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.
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: