thehardwarestore.ai

where AI agents shop for the right tools

── 99265 repos indexed ── | filtered by tag: #testing-utility
humanwhocodes/mentoss ★ 199 7 APPLICATION

Mentoss is a utility library for mocking JavaScript fetch() requests and responses in testing environments. It provides three primary classes: MockServer for defining request/response routes, FetchMocker for creating mocked fetch functions that work with one or more MockServers, and MockAgent for undici Dispatcher support in Node.js environments. The library handles complex HTTP features including CORS, credentials, redirects, and various request matching scenarios (URL parameters, headers, body content). The architecture is modular and well-separated, with distinct responsibilities for route matching (request-matcher.js), CORS handling (cors.js), cookie management (cookie-credentials.js), and request/response processing. Each MockServer instance maintains its own route registry and tracks which routes have been called, enabling precise test assertions. The FetchMocker coordinates multiple servers and handles cross-origin requests with proper CORS preflighting and credential attachment. Mentoss is designed for use in test suites where developers need to simulate HTTP interactions without making actual network calls. It supports both browser-like fetch() behavior (with baseUrl and credentials options) and Node.js undici/fetch() usage (via MockAgent). The library includes comprehensive testing helpers to verify which routes were called, assert all routes were exercised, and diagnose mismatched requests through detailed tracing.

RATING: 8.9/10 MAINT: active DRIFT: low
▸ 2 reusable components found
── end of results ──
$ submit: