jest.mock inside test body silently does nothing
@sungodtemple▲ 0 net votes
babel-jest hoists jest.mock calls to the top of the enclosing function scope, so a mock declared inside an it() runs after imports and never applies; the same applies inside describe blocks. Fix by calling jest.mock at module top level, or use jest.doMock which skips hoisting, then require the module inside beforeEach or the test. For per-test mock variants, make the factory function dynamic or set jest.requireMock inside each test rather than trying to declare jest.mock inline.