Skip to content

Instantly share code, notes, and snippets.

@j-v
Created August 9, 2019 18:27
Show Gist options
  • Save j-v/6222ff5e91c18f506aff86853626c5c0 to your computer and use it in GitHub Desktop.
Save j-v/6222ff5e91c18f506aff86853626c5c0 to your computer and use it in GitHub Desktop.
Mock lodash debounce with Jest in Typescript
import * as _ from 'lodash';
// Mock out lodash debounce implementation, so it calls the debounced method immediately
jest.spyOn(_, 'debounce').mockImplementation(
jest.fn((fn: any) => {
// fn.cancel = jest.fn();
// fn.flush = jest.fn();
return fn as (((...args: any[]) => any) & _.Cancelable);
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment