2

Is there a way in jasmine where I can combine toHaveBeenCalledTimes with toBeGreaterThan?

I want to know whether the spy object has called a particular method at least 2 times.

spy Object

spyOn(component.videos, 'update').and.callThrough();

I know we can verify it for exact number of times, but in my case update method can be called any number of times. I want to check if it has been called at least twice

something like below expect statement

expect(component.videos.update).toHaveBeenCalledTimes(2).toBeGreaterThan(2);

I know it is a wrong syntax, but is there anything similar to that?

Amit Chigadani
  • 28,482
  • 13
  • 80
  • 98

1 Answers1

2

They are different assertions that aren't supposed to be chained.

It likely should be:

expect(component.videos.update.calls.count()).not.toBeLessThan(2);
Estus Flask
  • 206,104
  • 70
  • 425
  • 565