Mongo-Mock (v4.2.0, last released 2022) is an in-memory mock implementation of the MongoDB server, designed to mimic the official MongoDB Node.js driver API. It allows developers to test MongoDB interactions without a real database, supporting basic CRUD operations, async simulation with configurable delay, optional disk persistence, and some query operators. Compared to alternatives like mongodb-memory-server, it is lighter-weight but has limited feature coverage and is no longer actively maintained.
npm install mongo-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connect to an in-memory mock, insert documents, and query them using async callbacks.
Set MongoClient.max_delay = 0 for synchronous behavior.
Check the GitHub issues or README for supported features. Use a different mock for complex pipelines.
Ensure you handle both callbacks and promises correctly. If using promises, omit the callback parameter.
Consider migrating to mongodb-memory-server for active support.
Use: const { MongoClient } = require('mongo-mock');Run: npm install mongo-mock
Call client.db() to get the db object before using collection.
Set MongoClient.max_delay = 0 or increase test timeout.
No dependency data recorded yet.