如何解决[因果服务器]:未捕获的异常

问题描述

我已经运行了Angular 9应用程序,并且正在使用以下命令在茉莉花中运行单元测试以运行测试,并且一切正常:

ng test

但是,当我使用watch = false运行单元测试时,所有测试都通过了,但是最后我得到的是“ UncaughtException ”。

ng test --watch=false // using this command in SonarQube to generate UT report

enter image description here

由于上述错误,SonarQube无法生成UT报告。

是否可以获取错误的详细信息(日志文件或其他内容)或调试[karma-server]“ UncaughtException错误...?

我从下面的规格文件中得到错误

profile.component.spec.ts

describe('Client.App.Advanced.ProfileComponent',() => {
    let component: ProfileComponent;
    let fixture: ComponentFixture<ProfileComponent>;
    let httpMock: HttpTestingController;

    function mockHttp(data) {
        const mockReq = httpMock.expectOne((req) => true);
        mockReq.flush(data);
        httpMock.verify();
    }

    beforeEach(async(() => {
        Testbed.configureTestingModule({
            imports: [HttpClientTestingModule,RouterTestingModule],declarations: [ProfileComponent],providers: [ProfiletoolHandlerService ]
        }).compileComponents();
    }));

    beforeEach(fakeAsync(() => {
        httpMock = Testbed.inject<HttpTestingController>(HttpTestingController);
        fixture = Testbed.createComponent(ProfileComponent);
        component = fixture.componentInstance;
        fixture.detectChanges();
        // mock request for Login
        mockHttp(null);
        tick();
    }));

    it('shall create the component',() => {
        fixture.detectChanges();
        expect(component).tobedefined();
    });
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)