Description of the bug
When using signal forms, if a component has an input:
items = input.required<FieldTree<Item[]>>();
And a value for this is provided via MockRender / MockRenderFactory:
const factory = MockRenderFactory(MyComponent, ['items']);
const formState = signal({ items: [{name: 'test'}] });
const formModel = TestBed.runInInjectionContext(() => form(formState));
const fixture = factory({ items: formModel.items });
const component = fixture.point.componentInstance;
expect(component).toBeTruthy();
Produces the following error:
TypeError: newCollection[Symbol.iterator] is not a function
The same also happens if using MockRender directly without runInInjectionContext, however that also provides a warning saying that form(...) must be in an injection context.
An example of the bug
Link:
https://codesandbox.io/p/devbox/keen-river-xhh7tg
Expected vs actual behavior
Expected is no error.
Also...
1: I realize signal forms are experimental etc.
2: It's kind of a chore to have to use the MockRenderFactory to get signal forms 'form()into an injection context. It would be awesome if we could do something likeMockRender(MyComponent, () => ({ items: form(formState).items }))`, where the provided callback creates component parameters inside the injection context.
Description of the bug
When using signal forms, if a component has an input:
And a value for this is provided via MockRender / MockRenderFactory:
Produces the following error:
The same also happens if using MockRender directly without
runInInjectionContext, however that also provides a warning saying thatform(...)must be in an injection context.An example of the bug
Link:
https://codesandbox.io/p/devbox/keen-river-xhh7tg
Expected vs actual behavior
Expected is no error.
Also...
1: I realize signal forms are experimental etc.
2: It's kind of a chore to have to use the MockRenderFactory to get signal forms 'form()
into an injection context. It would be awesome if we could do something likeMockRender(MyComponent, () => ({ items: form(formState).items }))`, where the provided callback creates component parameters inside the injection context.