Angular 测试时,除非承诺我得到超时
我对茉莉花和因果报应有测试问题 我的代码是:Angular 测试时,除非承诺我得到超时,angular,Angular,我对茉莉花和因果报应有测试问题 我的代码是: it('Should have component initialized', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb .createAsync(MainLayout) .then((rootTC: ComponentFixture) => {
it('Should have component initialized', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) =>
{
return tcb
.createAsync(MainLayout)
.then((rootTC: ComponentFixture) => {
mainLayout.getComponent(Component1).then((compRef)=>
{
expect(compRef).toBeDefined();//this will pase
expect(compRef).not.toBeDefined();//this will hang and I will get timeout eventually.
},(e)=>{
fail(e);
});
});
}));
MainLayout是一个组件,这就是我使用TestComponentBuilder的原因
问题是,当except与条件匹配时,一切都正常
如果没有,它只是挂起直到超时,并且没有像预期的那样通过测试。似乎“componentRef”有一个特定的问题,检查组件实例没有引起任何问题。似乎“componentRef”有一个特定的问题,检查组件实例没有引起任何问题。