Async Redis client mock object for unit testing that replaces async-redis in test environments. Current stable version is 2.0.1. It is actively maintained and offers in-memory Redis command simulation so that no actual Redis server is needed. Key differentiators: it provides a drop-in replacement for async-redis with a comprehensive set of mocked commands, allowing tests to run quickly and isolated. It supports common Redis commands like SET, GET, DEL, EXPIRE, and more, and integrates easily with testing frameworks like Jest and Mocha.
npm install async-redis-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a mock Redis client, set and get a key, then quit. Demonstrates in-memory operation.
Check the list of implemented commands in the documentation or consider using a different mock if you need full coverage.
If you are using ioredis, consider using 'ioredis-mock' instead.
Call 'client.flushall()' before each test or create a new client in beforeEach.
Use 'import mock from 'async-redis-mock'; const client = mock.createClient();' or 'const mock = require('async-redis-mock').default;' in CJS.Change to 'import asyncRedisMock from 'async-redis-mock';' or use 'const asyncRedisMock = require('async-redis-mock').default;'Use only implemented commands (SET, GET, DEL, etc.) or extend the mock manually.
Use 'import asyncRedisMock from 'async-redis-mock';' then 'asyncRedisMock.createClient()'.