At work, we recently converted from Mocha, Karma, Chai, and Sinon to Jest. It was not immediately obvious what the direct replacement was for
sinon.stub(object, 'methodName').callsFake(() => {})
Found out Jest provides similar functionality with
jest.spyOn(object, 'methodName').mockImplementation(() => {})
Top comments (7)
How to handle it if there is callback ?
What callback are you talking about? Got an example?
Does that work?
No. It says this expression is not callable. cb: unknow param
ThankYou very much... I have been looking for this exact thing for hours on internet
.... you saved my day
Thank you very much, I spent a lot of time trying to figure out how to solve this kind of problem.
Here's the solution.