如果您希望模拟在每次调用中返回不同的结果:
使用mockReturnValueOnce
myMock .mockReturnValueonce(10) .mockReturnValueonce('x') .mockReturnValue(true);将
10在第一个电话,
'x'第二个电话以及
true之后的任何时间返回。
如果要检查已使用模拟调用的参数:
用于toHaveBeenNthCalledWith
expect(mock).toHaveBeenNthCalledWith(1, 'first call args');expect(mock).toHaveBeenNthCalledWith(2, 'second call args');



