test spy nodejs code example
Example: sinon js
Sinon provides standalone test spies, stubs and mocks for JavaScript.
It works with any unit testing framework.
Spy -> Monitoring and verifying function behaviour
Stub -> Modify function behaviour / Replace difficult to test code
Mock -> Fake method for verifying multiple specific behaviours