在我的Angular 5应用程序中,我进行了一些冒烟测试或健全性检查,我希望一些服务能够进行真正的http调用,以确保下游依赖 endpoints 仍然有效/可访问 . 我已经尝试在TestBed中导入真正的HttpModule以及注入真正的实现,但看起来http调用没有通过 . 此外,我一直在挖掘文档,但我找不到任何结论性的想法 . 有没有人知道如何使它工作?

我目前的测试规范如下:

describe('My Smoke Test', () => {
    beforeEach(async (done) => {
    TestBed.configureTestingModule({
        providers: [
            { provide: Router, useValue: router },
            HttpRequestService,
            AppConfigService,
            ServerRoutingService,
            ProductService,
            {
                provide: APP_INITIALIZER,
                useFactory: appInitializerFn,
                multi: true,
                deps: [AppConfigService]
            }
        ],
        imports: [
            HttpModule
        ]
    })
    ...
   })

   it('Checking products endpoint', () => { 
      let productService = TestBed(ProductService)
      productService.getFirst().subscribe(
          response => expect(response.statusCode).toEqual(200),
      )
   })
})

我也尝试了async,fakeAsync,因为productService.getFirst()方法返回一个Observable,所以可能没有执行promise?