Quite often, microservices need to call other microservices, but we don't want to call the actual microservice; we just want to focus on whether the method was called
or not. For this, we have Sinon, a framework that gives us the options of mocks and spies, which fulfill our purpose by providing mock responses or creating a spy service. It provides the following:
- Stub: A stub is a dummy object with a prerecorded and specific response.
- Spy: A spy is a kind of hybrid between the real object and the mock. Some methods are shadowed by the spy object.
- Mock: A mock is a dummy object replacing the actual object.