A proposal for a mock module for ioredis
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
Solution: A proposal for a mock module for ioredis
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
Trust Score
3 verifications
- 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
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
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
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
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep