angular2-fixture.nativeElement.query中的ag-grid单元测试不是函数

时间:2018-08-28 04:51:53

标签: angular karma-jasmine ag-grid

我通过使用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']);
    });
  });

1 个答案:

答案 0 :(得分:1)

您应该在query()上使用fixture.debugElement。而且我也不认为您需要map这里的结果。

fixture.debugElement.query(By.css(".ag-fresh")).nativeElement应该为您做到。