Jet: Mock modules using a mock file

  1. Create a file like __mocks__/lodash/memoize.js:module.exports = a => a
  2. Add to your test:jest.mock(‘lodash/memoize’)

Note: When using babel-jest, calls to jest.mock will automatically be hoisted to the top of the code block. Use jest.doMock if you want to explicitly avoid this behavior.

Leave a Reply

Your email address will not be published. Required fields are marked *