You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using "ioredis": "^4.27.5" and have added some built in commands which i now want to use in the ioredis-mock but not able to do so. I am using "ioredis-mock": "^7.2.0"
in the unit testing file this is throwing an error
const Redis = require('ioredis-mock');
const { checkIfValidJsonAndReturnJson } = require('src/helpers/common/string');
// Transforming Replies
Redis.Command.setReplyTransformer('hgetall', result => {
if (Array.isArray(result)) {
const obj = {};
for (let i = 0; i < result.length; i += 2) {
obj[result[i]] = checkIfValidJsonAndReturnJson(result[i + 1]);
}
return obj;
}
return result;
});
Redis.Command.setReplyTransformer('hget', result => {
if (result && typeof result === 'string') {
result = checkIfValidJsonAndReturnJson(result);
return result;
}
return result;
});
Redis.Command.setReplyTransformer('JSON.GET', result => {
if (result && typeof result === 'string') {
result = checkIfValidJsonAndReturnJson(result);
return result;
}
return result;
});
const redisClient = new Redis();
redisClient.addBuiltinCommand('JSON.GET');
redisClient.addBuiltinCommand('JSON.SET');
redisClient.addBuiltinCommand('JSON.DEL');
redisClient.addBuiltinCommand('JSON.ARRAPPEND');
this is the error i get
TypeError: redisClient.addBuiltinCommand is not a function
at Object.<anonymous> (/Users/developer/syook/syook-tnt-server/specs/awilixContainerForTests.js:60:13)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Module._compile (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/@babel/register/node_modules/pirates/lib/index.js:136:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.newLoader [as .js] (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/@babel/register/node_modules/pirates/lib/index.js:141:7)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/Users/developer/syook/syook-tnt-server/specs/unit/service/ruleAlertGenerator.test.js:26:23)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Module._compile (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/@babel/register/node_modules/pirates/lib/index.js:136:24)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.newLoader [as .js] (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/@babel/register/node_modules/pirates/lib/index.js:141:7)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:203:29)
at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
at Loader.import (internal/modules/esm/loader.js:178:24)
at formattedImport (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
at Object.exports.requireOrImport (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
at Object.exports.loadFilesAsync (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
at singleRun (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at Object.exports.handler (/Users/developer/.nvm/versions/node/v14.21.2/lib/node_modules/mocha/lib/cli/run.js:370:5)
The text was updated successfully, but these errors were encountered:
I am using
"ioredis": "^4.27.5"
and have added some built in commands which i now want to use in the ioredis-mock but not able to do so. I am using"ioredis-mock": "^7.2.0"
in the unit testing file this is throwing an error
this is the error i get
The text was updated successfully, but these errors were encountered: