我似乎无法在网上找到解决方案。
这是一个代码示例,因此您会遇到问题:
// Spy on the wanted function
spyOn(object, 'myFunction');
// Call it 3 times with different parameters
object.myFunction('');
object.myFunction('', 0);
object.myFunction('', 0, true);
// Now all of these expects work
expect(object.myFunction).toHaveBeenCalledTimes(3);
expect(object.myFunction).toHaveBeenCalledWith('', 0);
expect(object.myFunction).toHaveBeenCalledWith('');
expect(object.myFunction).toHaveBeenCalledWith('', 0, true);
我想测试是否正确拨打了每个电话。有没有办法说这样的话?
expect(object.myFunction).nthCall(2).toHaveBeenCalledWith('', 0, true);
???