The primary use for spies is to gather information about function calls. … The function sinon. spy returns a Spy object, which can be called like a function, but also contains properties with information on any calls made to it.
What is Sinon used for?
Say Hello To Sinon JS. SinonJS is a JavaScript library that provides standalone test spies, stubs, and mocks. It’s very flexible and easy to use since you can combine it with any testing framework.
What is Spy in testing?
This is what is mostly used during unit testing. When spying, you take an existing object and “replace” only some methods. This is useful when you have a huge class and only want to mock certain methods (partial mocking).