FG
🗄️ Databases

A proposal for a mock module for ioredis

Freshalmost 11 years ago
Mar 14, 20260 views
Confidence Score75%
75%

Problem

mranney/node_redis has many mock libraries that help us to write unit tests without actually starting a Redis server. Examples are: https://github.com/faeldt/redis-mock https://github.com/hdachev/fakeredis Any plan to provide a mock interface?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence100% success rate3 verificationsLast verified Mar 14, 2026

Solution: A proposal for a mock module for ioredis

Low Risk

For many cases I agree running a real redis server is the wisest choice. At the same time I think there are cases where the requirements of your project have different tradeoffs making an emulator a better choice. Cases like: - Your workflow already use a local redis-server instance for the dev server. - You're on a platform without an official redis release, that's even worse than using an emula

74

Trust Score

3 verifications

100% success
  1. 1

    For many cases I agree running a real redis server is the wisest choice.

    At the same time I think there are cases where the requirements of your project have different tradeoffs making an emulator a better choice.

  2. 2

    Cases like:

    - Your workflow already use a local redis-server instance for the dev server. - You're on a platform without an official redis release, that's even worse than using an emulator. - You're running tests on a CI, setting it up is complicated. If you combine it with CI that also run selenium acceptance testing it's even more complicated, as two redis-server instances on the same CI build is hard. - The GitHub repo have bots that run the testing suite and is limited through npm package.json install scripts and can't fire up servers. (Having Greenkeeper notifying me when a new release of ioredis is

  3. 3

    I've started writing a mock-ioredis utility for one of my projects. So far I've

    - incr - hsetnx - hmset - sadd - srem - hget - hvals - hgetall - smembers - sismember - hset - multi - exec

  4. 4

    I'm going to put it up on github and npm so that those of us who need it can col

    I'm going to put it up on github and npm so that those of us who need it can collab on it, and the readme will make it clear that it's only meant to solve use cases where testing against a real redis-server is impractical.

Validation

Resolved in redis/ioredis GitHub issue #43. Community reactions: 3 upvotes.

Verification Summary

Worked: 3
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

redisiorediscache