「發送」我想測試我的角度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