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
When creating an Angular-component with MockRender, the actual component under testing becomes wrapped in another "dummy"-component. This creates a problem when you want to use ngMocks.formatHtml (and possibly formatText) to check if nothing is rendered within the component at all.
Our example is quite a bit bigger, but we listen to a service and render a template in a sidebar if there actually are anything emitted from the service. Now we want to test that logic, and formatHtml seems like it should be the correct way to do it.
An idea might be to check for isFixturehere and somehow get the inner / actual component.
Expected that ngMocks.formatHtml(MockRender(TargetComponent)) should return ''.
Actual is that ngMocks.formatHtml(MockRender(TargetComponent)) returns ''.
We can, in theory, test for the content to be ''. However, if you have any @input to the component it becomes difficult quite fast since the expectation might <app-target ng-reflect-text="TEST">TEST</app-target> instead. Also tried with fixture.debugElement but that seems to give the same result.
The text was updated successfully, but these errors were encountered:
Description of the bug
When creating an Angular-component with
MockRender
, the actual component under testing becomes wrapped in another "dummy"-component. This creates a problem when you want to use ngMocks.formatHtml (and possibly formatText) to check if nothing is rendered within the component at all.Our example is quite a bit bigger, but we listen to a service and render a template in a sidebar if there actually are anything emitted from the service. Now we want to test that logic, and
formatHtml
seems like it should be the correct way to do it.An idea might be to check for
isFixture
here and somehow get the inner / actual component.An example of the bug
Link: https://stackblitz.com/edit/github-lnydij?file=src%2Ftest.spec.ts
Expected vs actual behavior
Expected that
ngMocks.formatHtml(MockRender(TargetComponent))
should return ''.Actual is that
ngMocks.formatHtml(MockRender(TargetComponent))
returns ''.We can, in theory, test for the content to be ''. However, if you have any @input to the component it becomes difficult quite fast since the expectation might
<app-target ng-reflect-text="TEST">TEST</app-target>
instead. Also tried withfixture.debugElement
but that seems to give the same result.The text was updated successfully, but these errors were encountered: