tracker.reset([fn])
新增于: 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 tracker.getCalls(callsfunc).length === 1; tracker.reset(callsfunc); tracker.getCalls(callsfunc).length === 0;const assert = require('node:assert'); function func() {} const callsfunc = tracker.calls(func); callsfunc(); // Tracker was called once tracker.getCalls(callsfunc).length === 1; tracker.reset(callsfunc); tracker.getCalls(callsfunc).length === 0;