Angular的组件固定装置提供了一个方便的方法,称为whenStable()。它不特定于任何特定的异步事件。我想要一种工作原理类似于检测OnInit
,AfterViewInit
和AfterContentInit
何时运行的方法。
我可以直接通过component.ngOnInit()
调用它们,但是我不想测试生命周期挂钩中的逻辑,我希望框架调用它的后果(即绑定可用,模板已加载)等)。
我想要这样的东西:
it('should have template ready', async(async() => {
await fixture.afterViewInit();
// ... child component's can be interacted with
}));
我该怎么做?