-
In which I learned that jest-when exists to make js tests more spock-like github.com/timkindberg/jest-when @KentBeck/1197177958504398849
-
Finally being able to do this in one line inJS is nice: when(fn).calledWith(1).mockReturnValue('yay!')
-
And the even more useful expect version: when(fn).expectCalledWith(1).mockReturnValue('x')
-
not quite spock-equivalent though, as you can't expect multiple calls in this fashion: when(fn).expectCalledWith(1).mockReturnValue('x') when(fn).expectCalledWith(2).mockReturnValue('y') one of them will fail
-
but the workaround isn't bad: when(fn) .calledWith(1).mockReturnValue('yay!') .calledWith(2).mockReturnValue('nay!') //do the test.... verifyAllWhenMocksCalled()