简体   繁体   English

Angular 4,错误:无法解析 StateObservable 的所有参数:(?)

[英]Angular 4, Error: Can't resolve all parameters for StateObservable: (?)

i am writing unit test on one of my service.我正在为我的一项服务编写单元测试。 I am keep getting Error: Can't resolve all parameters for StateObservable: (?).我不断收到错误:无法解析 StateObservable: (?) 的所有参数。 and my test is failing.我的测试失败了。 can anyone tell me what is the issue?谁能告诉我是什么问题?

spec file code规范文件代码

fdescribe("Physician Service", () => {
let physicianService: PhysicianService;
let httpTestingController: HttpTestingController;
let backend: MockBackend;
let initialResponse: any;

beforeEach(() => {
 TestBed.configureTestingModule({
  imports: [
    HttpClientTestingModule
  ],
  providers: [
    Http,
    ConnectionBackend,
    UtilService,
    StateObservable,
    RouterModule,
    SessionService,
    HttpClientTestingModule,
    BaseRequestOptions,
    MockBackend,
    PhysicianService,
    AuthService,
    BrowserXhr,
    XHRBackend,
    Store,
    {
      deps: [
        MockBackend,
        BaseRequestOptions
      ],
      provide: Http,
      useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
        return new Http(backend, defaultOptions);
      }
    }
  ],
  schemas:[
    NO_ERRORS_SCHEMA
    ]
  });
 });

 fit("Should Create Physicians Service",
  inject([PhysicianService], (physicianService: PhysicianService) => {
    expect(physicianService).toBeTruthy();
    }));

 });

can anyone help me in this regard Thanks任何人都可以在这方面帮助我谢谢

This should have an actual answer instead of being in the comments.这应该有一个实际的答案,而不是在评论中。

In the TestBed.configureTestingModule imports add StoreModule.forRoot({})在 TestBed.configureTestingModule 导入中添加 StoreModule.forRoot({})

TestBed.configureTestingModule({
    imports: [
      ...
      StoreModule.forRoot({})
    ],
    providers: [
      ...
    ]
  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM