What Does Sinon Spy Do

What Does Sinon Spy Do

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).

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.