Skip to content

Instantly share code, notes, and snippets.

@rolspace
Last active November 22, 2018 22:02
Show Gist options
  • Save rolspace/bbf87598801a8b9db8cad1f7afbefb0c to your computer and use it in GitHub Desktop.
Save rolspace/bbf87598801a8b9db8cad1f7afbefb0c to your computer and use it in GitHub Desktop.
Syntax to mock object instance properties when using Jest
//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