Redis client mock object for unit testing. Current stable version is 0.56.3. It provides an in-memory mock of node_redis, allowing developers to test Redis-dependent code without an actual Redis server. Actively maintained but only 46% mock coverage (222/482 commands). Key differentiators: designed as a drop-in replacement for node_redis, supports common operations like strings, hashes, lists, sets, sorted sets, pub/sub, and transactions. However, it lacks complete command coverage and may not support all edge cases.
npm install redis-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: create client, set/get a key, cleanup.
Consider using alternatives like ioredis-mock or hand-rolling mocks.
Use util.promisify or wrap in a Promise.
Test thoroughly and consider alternatives for advanced pub/sub scenarios.
Stick to KEYS or use simple patterns.
Use require('redis-mock') or import redis from 'redis-mock'.Install and require/import the package correctly.
const { promisify } = require('util'); const getAsync = promisify(client.get).bind(client);Mock does not connect; ensure your test setup mocks 'redis' with 'redis-mock'.
No dependency data recorded yet.