Jasmine:澄清了使用第三方库时设置规范类的问题

时间:2018-06-29 01:57:40

标签: angular jasmine karma-jasmine ag-grid

可以说在我的角度应用程序的组件类中,我使用了第三方库(例如aggrid)。如果要测试使用这些第三方库的函数,则必须将必需的导入到我的spec类中,并且还复制我的app.module类?这是一个带有代码的简单示例。在此行中,选择了一行网格。这来自我的组件类。

`  rowsSelected() {
        return this.gridApi && this.gridApi.getSelectedRows().length > 0;
    }`

这是我的app.module类中@ngModule外观的示例。

    @NgModule({
  declarations: [
    Component,
   ],
     imports: [
          AgGridModule.withComponents([]),
       ]

现在在我的spec文件中,在导入时我会模仿相同的东西吗?像这样:

 beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ Component],
      imports: [AgGridModule.withComponents([])]
    })
    .compileComponents();
  }));

任何澄清都很好!

0 个答案:

没有答案
相关问题