The different tests mock a function from a module in a different way. All of them as per documentation. However none of them seem to be working.
Expected behavior
The mocked function should be mocked, making the tests pass and it's real implementation not executed, as a result of the mocking.
Actual behavior
None of the mocks work. The actual implementation of the mocked function runs and none of the expects calls are passing.
Additional context
I've tried different suggestions from different posts on StackOverflow but none seem to work. There is no transpilation in this setup.
The only thing that worked was changing all the call-sites to reference the fully exported function - i.e. instead of calling myFunctionToMock() I'd have to call module.exports.myFunctionToMock().
Version
29.7.0
Steps to reproduce
npm test
The different tests mock a function from a module in a different way. All of them as per documentation. However none of them seem to be working.
Expected behavior
The mocked function should be mocked, making the tests pass and it's real implementation not executed, as a result of the mocking.
Actual behavior
None of the mocks work. The actual implementation of the mocked function runs and none of the
expect
s calls are passing.Additional context
I've tried different suggestions from different posts on StackOverflow but none seem to work. There is no transpilation in this setup.
The only thing that worked was changing all the call-sites to reference the fully exported function - i.e. instead of calling
myFunctionToMock()
I'd have to callmodule.exports.myFunctionToMock()
.Environment