我正在尝试测试我的角度4.1.0组件 –
export class CellComponent implements OnInit { lines: Observable<Array<ILine>>; @Input() dep: string; @Input() embedded: boolean; @Input() dashboard: boolean; constructor( public dataService: CellService,private route: ActivatedRoute,private router: Router,private store: Store<AppStore>) { } }@H_502_3@但是,一个简单的“应该创建”测试会引发这个神秘的错误……
@H_502_3@NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘ng:///DynamicTestModule/module.ngfactory.js’.@H_502_3@所以我发现this问题,这表明问题是组件有@Input)_ params没有设置,但是,如果我修改我的测试如下:
it('should create',inject([CellComponent],(cmp: CellComponent) => { cmp.dep = ''; cmp.embedded = false; cmp.dashboard = false; expect(cmp).toBeTruthy(); }));@H_502_3@然后我仍然得到相同的问题,同样,如果我从组件中删除@Input()注释,仍然没有区别.我怎样才能通过这些测试?