You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using import inside unstable_mockModule results in an infinite loop (+heap out of memory error).
Using the example below but with unstable_mockModule results in an infinite loop
jest.mock('../myModule', () => {
// Require the original module to not be mocked...
const originalModule = jest.requireActual('../myModule');
return {
__esModule: true, // Use it when dealing with esModules
...originalModule,
getRandom: jest.fn(() => 10),
};
});
eg
jest.unstable_mockModule('../myModule', async () => {
// Require the original module to not be mocked...
const originalModule = await import('../myModule');
return {
...originalModule,
getRandom: jest.fn(() => 10),
};
});
Should this work or is this not a valid use case?
Expected behavior
unstable_mockModule works the same as jest.mock and allows import inside moduleFactory to inject original module.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Version
29.4.1
Steps to reproduce
Using
import
insideunstable_mockModule
results in an infinite loop (+heap out of memory error).Using the example below but with
unstable_mockModule
results in an infinite loopeg
Should this work or is this not a valid use case?
Expected behavior
unstable_mockModule
works the same asjest.mock
and allows import insidemoduleFactory
to inject original module.Actual behavior
Infinite loop
Additional context
No response
Environment
System: OS: Linux 6.0 Pop!_OS 22.04 LTS CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz Binaries: Node: 14.21.2 - /usr/bin/node npm: 6.14.18 - /usr/bin/npm
The text was updated successfully, but these errors were encountered: