angular2中的ag网格单元测试-fixture.nativeElement.query不是函数
我在angular中使用Karma/Jasmine为ag grid编写了一个测试用例。在我的测试用例中,只是检查ag网格头并得到错误,比如“fixture.nativeElement.query不是一个函数”,但我对我编写的方法是否正确没有足够的信心。如果有人有想法,请帮助我 这是我的测试用例angular2中的ag网格单元测试-fixture.nativeElement.query不是函数,angular,karma-jasmine,ag-grid,Angular,Karma Jasmine,Ag Grid,我在angular中使用Karma/Jasmine为ag grid编写了一个测试用例。在我的测试用例中,只是检查ag网格头并得到错误,比如“fixture.nativeElement.query不是一个函数”,但我对我编写的方法是否正确没有足够的信心。如果有人有想法,请帮助我 这是我的测试用例 it('测试列标题',()=>{ fixture.nativeElement.query(By.css(“.ag fresh”)) .map(函数(标题){ 返回header.getText() }).
it('测试列标题',()=>{
fixture.nativeElement.query(By.css(“.ag fresh”))
.map(函数(标题){
返回header.getText()
}).then(函数(标题){
expect(headers).toEqual(['color','qty','price']);
});
});
您应该在fixture.debugElement
上使用query()
。而且我认为你不需要把结果映射到这里
fixture.debugElement.query(By.css(“.ag fresh”)).nativeElement
应该为您做这件事。他们的任何源链接都可以使用Jasmine/Karma进行ag网格单元测试。