[英].length is not taking in Jasmine Karma unit testing
任何人都可以幫助我解決以下問題。
錯誤:TypeError:無法讀取未定義的屬性“ length”
組件文件:
@Input()
allPropertyLines: any[];
@Input()
completedPropertyLines: any[];
allPropertyLength: number = 0;
completedPropertyLength: number = 0;
ngOnInit() {
this.allPropertyLength = this.allPropertyLines.length;
this.completedPropertyLength = this.completedPropertyLines.length;
}
規格文件:
beforeEach(() => {
fixture = TestBed.createComponent(ListPropertyComponent);
comp = fixture.componentInstance;
comp.ngOnInit();
});
it('should create component', () => expect(comp).toBeDefined());
多謝你們!! 有用。
請記住一個簡單的事情,我應該提供以下輸入。
comp.allPropertyLines = [{}]。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.