Jest unit test for a debounce function
Actually, you don’t need to use Sinon to test debounces. Jest can mock all timers in JavaScript code. Check out following code (it’s TypeScript, but you can easily translate it to JavaScript): import * as _ from ‘lodash’; // Tell Jest to mock all timeout functions jest.useFakeTimers(); describe(‘debounce’, () => { let func: jest.Mock; let … Read more