Skip to content

Instantly share code, notes, and snippets.

@simianarmy
Created April 19, 2020 15:34
Show Gist options
  • Save simianarmy/71897bf02f8994338e9b695b396dfc76 to your computer and use it in GitHub Desktop.
Save simianarmy/71897bf02f8994338e9b695b396dfc76 to your computer and use it in GitHub Desktop.
Partial module mocks with dynamic mocks
import {random} from 'lodash'
jest.mock('lodash', () => {
return {
...jest.requireActual('lodash'),
random: jest.fn(),
}
});
test('get 5', () => {
random.mockImplementation(() => 5);
// test code
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment