Created
August 9, 2019 18:27
-
-
Save j-v/6222ff5e91c18f506aff86853626c5c0 to your computer and use it in GitHub Desktop.
Mock lodash debounce with Jest in Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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