Some code we’ve inherited from a supplier is using uploadStub.callsArg(2).returns({})
in Sinon to mock out the callback to a stubbed function. We’re migrating to jest and I’m struggling to find an equivalent.
The original function call being Upload(req, res, async function (error) { ... })
. It’s this 3rd arg which is a callback that I want to become a mock so the test can check it was called.
jestcodemods
has this PR https://github.com/skovhus/jest-codemods/pull/357 which suggests apiStub.mockImplementation((...args) => args[2]())
which would call the callback but not create a mocked version of it.