MockComponent function set Signal Inputs as Decorator Inputs · Issue #8887 · help-me-mom/ng-mocks · GitHub
More Web Proxy on the site http://driver.im/
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
henriquecustodia
changed the title
MockComponents set Signal Inputs as Decorator Inputs
MockComponent function set Signal Inputs as Decorator Inputs
May 3, 2024
P.S. I believe the issue's auhor initial request requires discussion.
Working with Signal Inputs, we need to test it as a Signal and not as a property as it was with Decorator Inputs.
input() vs @Input is a child component implementation detail. From the parent's perspective, the contract (component interface) hasn't changed. I believe the child's input type shouldn't affect parent component tests. Migration to signals should remain transparent to component consumers, including test code. Coupling a mock's behaviour to internal implementation details leads to unexpected test failures during migration to signals and is generally considered a bad practice.
I've noticed that Signal Inputs are just treated as Decorator Input.
I have the following component:
I mock the component using MockComponent function:
And my test try to access the Singal Input from
ListItemComponent
to assert its value:But the test breaks because the
task
property (it's a Signal Input) is not a function.The complete error:
TypeError: completedItemDebugEl.componentInstance.task is not a function
Logging the
<ListItemComponent>item.componentInstance).task
in the test, I see that it's a propertytask: { id: '1', name: 'Buy milk', completed: true }
Working with Signal Inputs, we need to test it as a Signal and not as a property as it was with Decorator Inputs.
Any news about that @satanTime?
Thank for your amazing work btw
The text was updated successfully, but these errors were encountered: