Last active
November 22, 2018 22:02
-
-
Save rolspace/bbf87598801a8b9db8cad1f7afbefb0c to your computer and use it in GitHub Desktop.
Syntax to mock object instance properties when using Jest
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
//mock object method | |
Object.defineProperty(object, 'method', { value: jest.fn() }); | |
//mock object property | |
Object.defineProperty(object, 'property', { get: () => jest.fn() }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment