ctx.calls


返回用于跟踪模拟调用的内部数组副本的获取器。数组中的每个条目都是一个具有以下属性的对象。

¥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> 传递给模拟函数的参数数组。

    ¥arguments <Array> An array of the arguments passed to the mock function.

  • error <any> 如果模拟函数抛出,则此属性包含抛出的值。默认值:undefined

    ¥error <any> If the mocked function threw then this property contains the thrown value. Default: undefined.

  • result <any> 模拟函数返回的值。

    ¥result <any> The value returned by the mocked function.

  • stack <Error> 一个 Error 对象,其堆栈可用于确定模拟函数调用的调用点。

    ¥stack <Error> An Error object whose stack can be used to determine the callsite of the mocked function invocation.

  • target <Function> | <undefined> 如果模拟函数是构造函数,则此字段包含正在构造的类。否则这将是 undefined

    ¥target <Function> | <undefined> If the mocked function is a constructor, this field contains the class being constructed. Otherwise this will be undefined.

  • this <any> 模拟函数的 this 值。

    ¥this <any> The mocked function's this value.