0

I have a redis get and set wrapper class that I want to test in my typescript nodejs backend API, and I was planning to use mocha and sinon to mock the redis methods with this:

const createClientStub = sanbox.stub(redis, 'createClient1');
// call createClient() in constructor
const store = new Store(new Config());
assert.calledOnce(createClientStub); <-- succeed
const getClientStub = sandbox.stub(redis.RedisClient, 'get') <-- `get` is undefined

For the error, it is referring to the ts redis method instead of the interface in the compiler:

export const RedisClient: new (options: ClientOpts) => RedisClient; <-- keeps referring to this one
export interface RedisClient extends Commands<boolean>, EventEmitter

I read the previous questions like:

0 Answers0