我通过使用Karma / Jasmine编写了一个用于ag-grid的测试用例。在我的测试用例中,仅检查ag-grid标头并得到诸如“ fixture.nativeElement.query不是函数”之类的错误,但我不确定这是否是正确的方法,我是否已经写过。如果有人有想法请帮助我。
这是我的测试用例
it('to test the column headers',()=>{
fixture.nativeElement.query(By.css(".ag-fresh"))
.map(function (header){
return header.getText()
}).then(function(headers){
expect(headers).toEqual(['color','qty','price']);
});
});
答案 0 :(得分:1)
您应该在query()
上使用fixture.debugElement
。而且我也不认为您需要map
这里的结果。
fixture.debugElement.query(By.css(".ag-fresh")).nativeElement
应该为您做到。