Jest for Sinon Stubs
(Source/Credits: https://dev.to/2ezpz2plzme/jest-for-sinon-stubs-5bdb)
At work, we recently converted from Mocha, Karma, Chai, and Sinon to Jest. It was not immediately...
title: Jest for Sinon Stubs published: true description: tags: #testing #JavaScript #jest #sinon
At work, we recently converted from Mocha, Karma, Chai, and Sinon to Jest. It was not immediately obvious what the direct replacement was for tsx
sinon.stub(object, 'methodName').callsFake(() => {})
Found out Jest provides similar functionality with
tsx
jest.spyOn(object, 'methodName').mockImplementation(() => {})
Comments section
afsarzan
•May 1, 2024
How to handle it if there is callback ?
2ezpz2plzme Author
•May 1, 2024
What callback are you talking about? Got an example?
danieldfc
•May 1, 2024
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.
hellixum
•May 1, 2024
ThankYou very much... I have been looking for this exact thing for hours on internet
.... you saved my day