jest.mock() doesn’t work inside tests, only outside tests
Use mockReturnValue(…) import { getCallingCode, hasSupport, } from ‘utils/countryCallingCode’ jest.mock(‘utils/countryCallingCode’, () => ({ getCallingCode: jest.fn(), hasSupport: jest.fn(), })) describe(‘…’, () => { it(‘…’, () => { getCallingCode.mockReturnValue(1) hasSupport.mockReturnValue(false) expect(… }) it(‘…’, () => { getCallingCode.mockReturnValue(0) hasSupport.mockReturnValue(true) expect(… }) }) Dealing with default export from that util: import theUtil from ‘utils/theUtil’ jest.mock(‘utils/theUtil’, () => ({ __esModule: … Read more