I am trying to mock external dependency which is not yet published in npm repository.
import Utils from 'external-dependency';
jest.mock('external-dependency', () => ({
default: ()=> jest.fn()
}));
Above jest mocking display following error since that dependency not yet exist.
Cannot find module 'external-dependency'
How to mock non-exist dependency in Jest?
As stated in the reference,
Also notice that
jest.mock
return value translates to CommonJS module by default. In case of ES module, it should be: