Skip to content

Bug: Signal Forms FieldTree as component param in MockRender corrupts parameter #13089

@wimbarelds

Description

@wimbarelds

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions