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
jest.mock('../path/to/module',()=>({exportedFunction: jest.fn(()=>async()=>{}),// obviously a thunk action});
I also use the configuration variable resetMocks.
It looks like that the mocks seem to be reseted after the module factory has been called, while it should be reseted before so that any created mock inside the factory isn't reset.
As a result when we use the mocked functions inside a test, they return undefined instead of the expected return value, and the code fails.
Expected behavior
I expect that the return value defined in the module factory is kept even though I use resetMocks.
Especially I expect that the factory function is called again at each test. But maybe this is a wrong assertion...
This issue was closed because it has been stalled for 7 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.
🐛 Bug Report
I use something like this in my test file:
I also use the configuration variable
resetMocks
.It looks like that the mocks seem to be reseted after the module factory has been called, while it should be reseted before so that any created mock inside the factory isn't reset.
As a result when we use the mocked functions inside a test, they return undefined instead of the expected return value, and the code fails.
Expected behavior
I expect that the return value defined in the module factory is kept even though I use
resetMocks
.Especially I expect that the factory function is called again at each test. But maybe this is a wrong assertion...
Link to repl or repo (highly encouraged)
https://repl.it/repls/SecondhandSteelScripts
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: