A Redis mock for Node.js development, providing in-memory simulation of Redis commands (strings, hashes, lists, pub/sub, transactions, keys, server) without a real Redis server. Current stable version 0.91.13, low release cadence (last update 2016). Designed for unit testing Node.js applications that use the redis npm package. Supports CommonJS require, no TypeScript definitions, no ESM support. Key differentiator: can create a mock redis module that mimics the real redis.createClient API, allowing drop-in replacement. Limited command coverage compared to alternatives like ioredis-mock, and no longer actively maintained.
npm install mock-redis-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use createMockRedis to get a mock client, perform set/get on a string, hset/hgetall on a hash, and cleanup.
Use require('mock-redis-client') instead of import.const mockRedis = require('mock-redis-client').createMockRedis(); const client = mockRedis.createClient();Consider using ioredis-mock or redis-mock for up-to-date alternatives.
Do not rely on dbsize for testing; use keys or information commands if needed.
Wrap with promisify or use a library that supports promises.
const redis = require('mock-redis-client').createMockRedis(); const client = redis.createClient();npm install redis --save-dev or remove the optional dependency (the mock works without redis).
Use callbacks: client.set('key', 'val', callback) or wrap with util.promisify.Switch to CommonJS require, or use a dynamic import workaround (not recommended).