In jest there is a method called .toHaveBeenNthCalledWith which you can pass the nth call and check if that call was with specific params.
Now I want to check the same in jasmine (in angular unit tests), what is the the way in jasmine?
You can use Spy#calls argsFor(index).
const mySpy = spyOn(myObject, 'methodName');
// do some stuff
expect(myObject.methodName).toHaveBeenCalledTimes(expectedNumberOfInvocations);
const arguments = mySpy.calls.argsFor(nthInvocation);
// check arguments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With