Unit Test a Function that Invokes a Callback with a Sinon Spy

Share this video with your friends

Send Tweet

Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to create a fake callback function can simplify your unit tests while still allowing you to observe the output of the function you're testing.