Open
Description
Version
27.2.1 & 29.6.2 & 29.6.3
Steps to reproduce
I made a mini repo to reproduce the issue. This is to reopen #14443
Expected behavior
I expect this test to pass
/* in __mocks__ folder, lodash is mocked by the file below
lodash.ts
*/
import * as exportsFromIndexFile from "./index";
import {range} from 'lodash'
let indexModule : typeof exportsFromIndexFile
beforeEach(()=>{
jest.isolateModules(()=>{
indexModule = require('./index')
})
})
it('mocks for a library in node_modules are not working', () => {
indexModule.helloWorld(). // helloWorld is using lodash.range inside
expect(range).toHaveBeenCalled()
});
Actual behavior
But expect(range).toHaveBeenCalled()
failed. It says lodash.range
was not called. If I use debugger, I can see that the it's been called.
Additional context
No response
Environment
System:
OS: macOS 13.5.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 18.17.0 - ~/Library/Caches/fnm_multishells/24849_1670237417415/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.6.7 - ~/Library/Caches/fnm_multishells/24849_1670237417415/bin/npm
npmPackages:
jest: 29.6.3 => 29.6.3