Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the nth call args in Jasmine

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?

like image 555
Reza Avatar asked Nov 15 '25 07:11

Reza


1 Answers

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
like image 117
uminder Avatar answered Nov 17 '25 22:11

uminder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!