test
The MockTracker API in Node.js provides a means of tracking and managing mock objects in a test
environment.
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 calledconsole.log(fn.mock.calls[0].arguments)); // Recoreds the arguments that were passed each callThe full MockTracker API is documented in the Node.js documentation for MockTracker โ.
The Workers implementation of MockTracker currently does not include an implementation of the Node.js mock timers API โ.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark