Registry / testing / redis-js

redis-js

JSON →
library0.1.2jsnpmunverified

An in-memory Redis-compatible mock implementation in pure JavaScript, ideal for testing Redis-dependent code without a real server. Version 0.1.2 (stable, low release cadence) supports core Redis commands (SET, GET, DEL, pub/sub, createClient) with blocking, callback, async, and promise styles. Unlike other mocks, it runs entirely in-memory and can be used in both Node.js and browser environments. No network overhead, no external dependencies.

npm install redis-js
INSTALL
IMPORT
SIG · REDIS-JS
R
redis-js
testingjavascriptv0.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
var redis = require('redis-js');
import redis from 'redis-js';
Package uses CommonJS only; ESM import not supported.
createClient
var client = redis.createClient();
var client = new redis.Client();
createClient is a function, not a constructor. It returns a client instance.
redismock (browser global)
var redis = window.redismock;
var redis = require('redis-js'); // not available in browser
In the browser, the library is exposed as window.redismock via a script tag.

Demonstrates basic synchronous usage: SET, GET, and DEL commands with an in-memory mock.

var redis = require('redis-js'); var reply = redis.set('key', 'value'); if (reply === 'OK') { var value = redis.get('key'); console.log(value); // 'value' redis.del('key'); }
Debug
Known issues
gotchaThe library uses blocking synchronous calls by default, not async I/O. Callbacks are optional and do not change synchronous execution.
fix
Use callbacks or promises only for consistency; actual I/O is never asynchronous.
affects: >=0.0.1
breakingPub/sub uses same synchronous model; message delivery happens immediately on publish.
fix
Do not expect real Redis async behavior; this is a mock for basic testing.
affects: >=0.0.1
gotchacreateClient ignores all arguments and returns a copy hooked to the same in-memory store as the base module.
fix
Passing port, host, or options will have no effect.
affects: >=0.0.1
deprecatedThe package has not been updated since 2016 and may not support newer Redis commands (e.g., SCAN, streams).
fix
Consider using ioredis-mock or redis-mock for more complete coverage.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: redis.createClient is not a function
Using 'require('redis-js')' directly as a function instead of calling redis.createClient()
fix
var client = require('redis-js').createClient();
ReferenceError: redismock is not defined
Trying to require the library in a browser environment; it's exposed globally as 'redismock'
fix
Use <script src='redis-mock.min.js'> and then window.redismock
Error: redisClient.get is not a function
Calling get on an undefined client; likely created client incorrectly
fix
var redis = require('redis-js'); var client = redis.createClient(); client.get('key');
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
redis-js — npm install redis-js · libregistry