Today I Learned

TIL, 2021-09-29 - Some Grokking Observables

  • expect.assertions to test that something has been asserted.
  • The way to do a spec: re making sure async stuff finished:

component.ngOnInit();

localeFacade.selectedLocale$
  .pipe(count())
  .subscribe((numberOfLocaleChanges) => {
    expect(loadLoyaltyProgramsSpy).toHaveBeenCalledTimes(
      numberOfLocaleChanges,
    );

    done();
  });
  • You can do something like this:
await expect(localeFacade.selectedLocale$.pipe(count()).toPromise()).resolves.toEqual(2);

This project is maintained by daryllxd