tracker.getCalls(fn)


  • fn <Function>

  • 返回:<Array> 包含对跟踪函数的所有调用的数组。

    ¥Returns: <Array> An array with all the calls to a tracked function.

  • 对象 <Object>

    ¥Object <Object>

    • thisArg <Object>

    • arguments <Array> 传递给跟踪函数的参数

      ¥arguments <Array> the arguments passed to the tracked function

import assert from 'node:assert';

const tracker = new assert.CallTracker();

function func() {}
const callsfunc = tracker.calls(func);
callsfunc(1, 2, 3);

assert.deepStrictEqual(tracker.getCalls(callsfunc),
                       [{ thisArg: undefined, arguments: [1, 2, 3] }]);const assert = require('node:assert');

// Creates call tracker.
const tracker = new assert.CallTracker();

function func() {}
const callsfunc = tracker.calls(func);
callsfunc(1, 2, 3);

assert.deepStrictEqual(tracker.getCalls(callsfunc),
                       [{ thisArg: undefined, arguments: [1, 2, 3] }]);