Back to Sinon

spy.getCall

docs/concepts/spies/api/get-call.md

22.1.0757 B
Original Source

spy.getCall

Returns the nth (zero-indexed) call recorded by the fake, spy or stub.

If n is negative, the nth call from the end is returned. For example, spy.getCall(-1) returns the last call, and spy.getCall(-2) returns the second to last call.

Accessing individual calls helps with more detailed behavior verification when the spy is called more than once.

<<< ../../../.vitepress/tests/docs/spies/api/get-call.test.js

Resetting getCall to default

You can reset the call history in three different ways: