Issue with overriding standalone component's imports #11821
MikeDabrowski
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a SidepanelModule and its custom mock SidepanelTestingModule. They do not use ngMocks's builder - just plain TestBed setup. I added MockComponent for some less important components but that shouldn't matter here. When testing any standalone component that imports SidepanelModule, I want to override that and use SidepanelTestingModule instead. To do that I use
overrideComponent
with{ remove: [SidepanelModule], add: [SidepanelTestingModule] }
. However it doesn't work.I was inspecting how the overrides are applied and I found out that upon initialization the component in test is "overriden" with
set
and this set includes what is in the components imports. BUT, here's the catch: some imports are automatically wrapped in a mock. So I am getting MockOfSidepanelModule. Then, when my override tries to remove SidepanelModule it fails to do so and just adds SidepanelTestingModule.I experimented with adding
remove: [SidepanelModule, MockModule(SidepanelModule)] }
and even globalReplace/keep.Does this MockOf... come from ngMocks even when not explicitly mocked?
Beta Was this translation helpful? Give feedback.
All reactions