Javascript Jasmine tohaveBeenCalledWith()对象比较

Javascript Jasmine tohaveBeenCalledWith()对象比较,javascript,jasmine,Javascript,Jasmine,我的jasmine测试目前在expect(mySpy)上失败。toHaveBeenCalledWith(myArray)带有以下消息,我不确定如何解释: 应使用[Object]调用spy mySpy({type:Function, 名称:'foo',值:[[对象({type:函数,名称:'one'值: 对象({type:Function,name:'two',value:'2'}),…]}) ] 但实际调用是[Object({type:Function,name:'foo',value: [[O

我的jasmine测试目前在
expect(mySpy)上失败。toHaveBeenCalledWith(myArray)
带有以下消息,我不确定如何解释:

应使用[Object]调用spy mySpy({type:Function, 名称:'foo',值:[[对象({type:函数,名称:'one'值: 对象({type:Function,name:'two',value:'2'}),…]}) ]

但实际调用是[Object({type:Function,name:'foo',value: [[Object,Object,…]}]


请注意,预期的对象具有
value
属性的完整类型和值,但在实际调用中,Jasmine只发现它们是对象,没有关于它们的内部值的详细信息。我知道jasmine很难比较函数,您需要将相同的引用传递给这两个函数,我就是,但是为什么jasmine没有给出实际调用的全部细节,为什么仅仅因为它们是对象就失败了?

这很奇怪,我这样处理这个问题:

// get a handle on the arguments that the most recent call the spy was invoked with
const arguments = mySpy.calls.mostRecent().args;
console.log({ arguments });
expect(arguments[0]).toBe(....); // assert the first argument to be of ...

谢谢,这似乎是我测试的一个变通方法,而
.toEqual()
检查对于参数来说似乎很有效。仍然不确定为什么
.toHaveBeenCalledWith()
会以不同的方式失败