tracker.reset([fn])
新增于: v18.8.0, v16.18.0
-
fn<Function> 一个要重置的跟踪函数。\
fn<Function> a tracked function to reset.
重置调用跟踪器的调用。如果被跟踪的函数作为参数传递,调用将被重置。如果没有传递参数,所有跟踪的函数将被重置。
\Reset calls of the call tracker. If a tracked function is passed as an argument, the calls will be reset for it. If no arguments are passed, all tracked functions will be reset.
import assert from 'node:assert'; const tracker = new assert.CallTracker(); function func() {} const callsfunc = tracker.calls(func); callsfunc(); // Tracker was called once assert.strictEqual(tracker.getCalls(callsfunc).length, 1); tracker.reset(callsfunc); assert.strictEqual(tracker.getCalls(callsfunc).length, 0);const assert = require('node:assert'); const tracker = new assert.CallTracker(); function func() {} const callsfunc = tracker.calls(func); callsfunc(); // Tracker was called once assert.strictEqual(tracker.getCalls(callsfunc).length, 1); tracker.reset(callsfunc); assert.strictEqual(tracker.getCalls(callsfunc).length, 0);