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 third arg which is a callback that I want to become a mock so the test can return an actual value.
jestcodemods has this PR which suggests
apiStub.mockImplementation((...args) => args[2]())
which would call the callback but not create a mocked version of it.
So, it turns out the
jestcodemodssolution works with no need to make it return a value.