I was updating ng-mocks from 13.0.0-alpha.6 to 14.11.0, and I noticed something strange, we have wrapper component that we use for some testing, our testbed configuration looks like this
TestBed.configureTestingModule({
declarations: [
WrapperType,
ComponentToBeTested,
MockComponent(x),
MockDirective(y),
],
});
wrapper type is just a dumb wrapper component that's encapsulating ComponentToBeTested, so think of it as just a parent component. Its template looks like this.
<wrapper><component-to-be-tested></component-to-be-tested></wrapper>
We create an instance of the wrapper component.
fixture = TestBed.createComponent(WrapperType);
previously, this fixture would render the actual type of ComponentToBeTested
, so you can see the actual template included in the wrapper type if you check fixture.nativeElement
<div root>
<component-to-be-tested> <p> test dom that's included in the original template of component to be tested </p> </component-to-be-tested>
</div>
but after the update, ComponentToBeTested that's included in wrapper type is just an empty mock
<div root>
<component-to-be-tested></component-to-be-tested>
</div>
This is kind of ruining our tests, what I don't understand is how did the update impact testbed, because for those cases, we aren't even using MockBuilder, we are just using MockComponent for components that aren't related to the test, and ComponentToBeTested
isn't one of them.
of course ideally this wrapper type nonsense shouldn't be even needed because I understand that ng-mocks is already doing this job for us, but it was done long time ago, and refactoring every test for this update isn't an option for now.
Any help to get around this will be appreciated.
This issue here was in the wrapper component which uses internal logic of ng-mocks
and breaks therefore breaks its behavior.
More details are here: https://github.com/help-me-mom/ng-mocks/issues/6063
The fix is to remove mockOf: { value: mockClass },
in the wrapper.