跳转到内容
搜索文档

test

最后更新 查看 MarkdownAgent 设置

MockTracker

Node.js 中的 MockTracker API 提供在测试环境中跟踪和管理 mock 对象的方法。

import { mock } from 'node:test';

const fn = mock.fn();
fn(1,2,3);  // does nothing... but

console.log(fn.mock.callCount());  // Records how many times it was called
console.log(fn.mock.calls[0].arguments);  // Records the arguments that were passed each call

完整的 MockTracker API 文档见 Node.js MockTracker 文档

Workers 的 MockTracker 实现目前不包含 Node.js mock timers API 的实现。

这篇文档对您有帮助吗?