vendredi 4 décembre 2020

testing subscribe in karma gives error Argument of type 'Observable<>' is not assignable to parameter of type 'Subscription'

I have this method

loadCombos(): void {
  this.combosService.accounts$.subscribe(
    (data: any) => {
    this.list = data;
      }
    }
  );
}

and this is my current test:

it('should test loadCombos executions ', (done) => {
  combosService = TestBed.inject(CombosService);
  spyOn(combosService.accounts$, 'subscribe').and.returnValue(of(mockList));
  component.loadCombos();
  expect(component.list).not.toBeNull();

  done();
});

how can I use mockList on my test, currently I'm getting that's an observable but it needs a suscription, but I don't know how to do it.

Aucun commentaire:

Enregistrer un commentaire