Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 测试时,除非承诺我得到超时_Angular - Fatal编程技术网

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”有一个特定的问题,检查组件实例没有引起任何问题。