Closed materkel closed 3 years ago
Thank you very much for this contribution!
Do you know will this also work with a mock that has an existing mockReturnValue as well?
See #59
Just checked the test setup @narthur provided in #59 with my solution, unfortunately this does not work, the original jest setup still has to be defined before calling when on it in this case.
const fn = jest.fn()
when(fn).calledWith(1).mockReturnValue('a')
fn.mockReturnValue('b')
expect(fn(1)).toEqual('a') // fails and will still return 'b' (as before my change)
expect(fn(2)).toEqual('b')
Not sure if #59 is solved quite as easily (from my limited understanding of the code)
resolves #78
imo this is also more in line with the jest default behavior