简体   繁体   中英

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: (?). 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({
    imports: [
      ...
      StoreModule.forRoot({})
    ],
    providers: [
      ...
    ]
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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