ctx.calls
返回用于跟踪模拟调用的内部数组副本的获取器。 数组中的每个条目都是一个具有以下属性的对象。
arguments
<Array> 传递给模拟函数的参数数组。error
<any> 如果模拟函数抛出,则此属性包含抛出的值。 默认值:undefined
。result
<any> 模拟函数返回的值。stack
<Error> 一个Error
对象,其堆栈可用于确定模拟函数调用的调用点。target
<Function> | <undefined> 如果模拟函数是构造函数,则此字段包含正在构造的类。 否则这将是undefined
。this
<any> 模拟函数的this
值。
A getter that returns a copy of the internal array used to track calls to the mock. Each entry in the array is an object with the following properties.
arguments
<Array> An array of the arguments passed to the mock function.error
<any> If the mocked function threw then this property contains the thrown value. Default:undefined
.result
<any> The value returned by the mocked function.stack
<Error> AnError
object whose stack can be used to determine the callsite of the mocked function invocation.target
<Function> | <undefined> If the mocked function is a constructor, this field contains the class being constructed. Otherwise this will beundefined
.this
<any> The mocked function'sthis
value.