【问题标题】:ag-grid unit testing in angular2- fixture.nativeElement.query is not a functionangular2-fixture.nativeElement.query 中的 ag-grid 单元测试不是函数
【发布时间】:2019-02-02 15:23:45
【问题描述】:

我使用 Karma/Jasmine 为 Angular 中的 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']);
    });
  });

【问题讨论】:

    标签: angular karma-jasmine ag-grid


    【解决方案1】:

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

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

    【讨论】:

    • 他们的任何源链接是否可用于使用 Jasmine/Karma 进行 ag-grid 单元测试。
    猜你喜欢
    • 2020-02-28
    • 2017-07-07
    • 2021-01-15
    • 2020-06-28
    • 2021-04-03
    • 2020-08-08
    • 2020-03-10
    • 1970-01-01
    • 2020-09-06
    相关资源
    最近更新 更多