“发送”我想测试我的角度4.1.0组件 -角测试与未能执行失败的“XMLHttpRequest的”
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>) {
}
}
但是,一个简单的“应建立”测试抛出这个神秘的错误。 ..
NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/module.ngfactory.js'.
所以我发现this问题,这表明问题是组件具有@Input)_
PARAMS未设置,但是,如果我修改我的测试,像这样:
it('should create', inject([CellComponent], (cmp: CellComponent) => {
cmp.dep = '';
cmp.embedded = false;
cmp.dashboard = false;
expect(cmp).toBeTruthy();
}));
然后我仍然得到同样的问题,同样,如果我从组件中删除@Input()
注释,仍然没有区别。我怎样才能让这些测试通过?
为了创建组件,您需要提供所有依赖关系。 你能显示你所有的测试设置吗?我将尝试在[plnkr]上重现该问题(http://plnkr.co/edit/mRT1WDo4tI8IRIaHHcyS) –
我遇到了同样的问题,并找到了与您相同的帖子。我能找到解决方案。我结束了在其他问题上发布,但你可以看看这里:https://stackoverflow.com/a/45419372/6739517希望它有帮助! –
看到这个:https://github.com/angular/angular-cli/issues/7296 – titusfx