I am not able to understand how imports work in unit tests with jest. I was trying to mock a hook exported from someFile
jest.mock('src/someFile', () => ({
useFetch: () => ({ ... }),
}));
When it's written outside the described block, I am able to run the test as expected. However, moving the jest mock block inside the describe block or a test block doesn't work.
describe('someHOC', () => {
jest.mock('src/someFile', () => ({
useFetch: () => ({ ... }),
}));
// Followed by tests
});
Can someone suggest to me if we can make it work the same way with some changes, or is it not possible? Also, is __esModule: true, required in this case, why or why not?