-
Good SO post: https://stackoverflow.com/questions/53174202/how-to-mock-a-function-in-jest
-
Good Medium post: https://medium.com/@qjli/how-to-mock-specific-module-function-in-jest-715e39a391f4
-
Good discussion here: jestjs/jest#936 (comment)
-
Personal experience
-
import the module as a whole. for instance, import * as Blah from '../blah';
-
const mock = jest.spyOn(Blah, '<mocked_function_name>');
-
mock.mockImplementationOnce( () => {});
Last active
June 28, 2019 03:21
-
-
Save kafkahw/c9b286978982a7017253c4c44b79db30 to your computer and use it in GitHub Desktop.
how to mock exported functions in module in Jest
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment