ag - gridReady在Angular和Jest的测试中没有被调用



在Jest测试中没有调用Angular AG Grid的gridReady方法。你知道为什么吗?

这里是我的测试代码:

import {TestBed} from "@angular/core/testing";
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing";
import {AppComponent} from "./app.component";
import {FormsModule} from "@angular/forms";
import {AgGridModule} from "ag-grid-angular";
describe('AG Grid', () => {
it('calls grid ready', async()=> {
TestBed.resetTestEnvironment();
TestBed.initTestEnvironment(BrowserDynamicTestingModule,
platformBrowserDynamicTesting());
await TestBed.configureTestingModule({
imports: [
FormsModule,
AgGridModule.withComponents([]),
],
declarations: [AppComponent]
}).compileComponents();
const fixture = TestBed.createComponent(AppComponent);
const component = fixture.componentInstance;
fixture.detectChanges();
expect(component.api).toBeDefined();
expect(component.columnApi).toBeDefined();
});
})

在这里你可以看到它的代码沙箱。这是一个GitHub存储库。

await fixture.whenStable()代替fixture.detectChanges()

相关内容

  • 没有找到相关文章

最新更新