Search code examples
angularrxjsangular-testjasmine-marblesrxjs-marbles

rxjs-marbles testing has no expectations


I use rxjs-marbles for testing observables in my Angular 7 app. But it looks like m.expect is not recognized by jasmine as expectation.

I have following test:

it('should see expectations', marbles(m => {
  const source: Observable<Message> = m.hot('^a--b--c');
  m.expect(source).toBeObservable('-a--b--c');
}));

When I run it I get error in console:

ERROR: 'Spec 'FeatureFlagsService should see expectations' has no expectations.'

Also in browser output my test is prefixed with:

SPEC HAS NO EXPECTATIONS should see expectations

Adding expect(true).toBe(true); fixes the issue but this is not really way I want to go.

How to register m.expect as a expectation for jasmine?


Solution

  • It was actually cased by the lib itself. I created an issue on github and it was solved quickly: https://github.com/cartant/rxjs-marbles/issues/51