If you create an instance with new , you cannot do anything to assign this field. You can use TestComponentBuilder to get change detection and binding.
Below is an example of dart code that checks the BwuArraySelector component. I assume that you can understand how to do this in TS.
/// Component only for testing BwuArraySelector @Component( selector: 'test-cmp-singleconfigured', directives: const [BwuArraySelector], template: ''' <bwu-array-selector #singleConfigured [items]='[{"name": "one"},{"name": "two"},{"name": "three"}]'> </bwu-array-selector> ''') class SingleConfigured { @ViewChild('singleConfigured') BwuArraySelector arraySelector; }
...
// inject the TextComponentBuilder and create a component instance ngTest('single selection', (TestComponentBuilder tcb) async { ComponentFixture tc = await tcb.createAsync(SingleConfigured); tc..detectChanges(); BwuArraySelector el = (tc.componentInstance as SingleConfigured).arraySelector;
The detectChanges() call initializes the inputs of the BwuArraySelector with the values โโfrom the template bindings of the SingleConfigured components.
source share