Mentoss is a lightweight, TypeScript-first utility for mocking fetch() requests and responses in Node.js (>=18.18) and browser environments. Version 0.13.0 (July 2024) provides three core classes — MockServer, FetchMocker, and MockAgent — to define server routes, replace global fetch, and intercept undici requests. Unlike similar libraries (e.g., nock, msw), Mentoss focuses exclusively on fetch() and undici, supporting both ESM and CommonJS through conditional exports, shipping type definitions, and offering a minimal API with built-in route tracking and assertion helpers. The package is authored by Nicholas C. Zakas (ESLint creator) and has a release cadence of approximately monthly updates.
npm install mentossNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a MockServer with a GET route, creates a FetchMocker, makes a fetch call, and verifies the route was called.
Switch to ESM imports (import { MockServer } from 'mentoss') or use dynamic import() in CJS context.Run Jest with node --experimental-vm-modules ./node_modules/.bin/jest and add 'mentoss' to transformIgnorePatterns exception.
Do not pass baseUrl or credentials to MockAgent; configure those via MockServer routes if needed.
Replace mocker.routesCalled() with mocker.allRoutesCalled().
Use import { MockServer } from 'mentoss' instead of require().Use named import: import { MockServer } from 'mentoss'.Enable ESM support in Jest: use node --experimental-vm-modules jest and add 'mentoss' to transformIgnorePatterns in jest.config.
Install undici: npm install undici.
No dependency data recorded yet.