Skip to content

Instantly share code, notes, and snippets.

@gbalbuena
Created October 30, 2019 05:44
Show Gist options
  • Select an option

  • Save gbalbuena/799de71c9ba50a21eb9e602866e9da54 to your computer and use it in GitHub Desktop.

Select an option

Save gbalbuena/799de71c9ba50a21eb9e602866e9da54 to your computer and use it in GitHub Desktop.
jest mock library for async-redis deps, it has to be in __mock__ dir
let mock = { mock: true };
const client = {
set: function() {
},
get: function() {
return JSON.stringify(mock)
},
quit: function() {
}
}
function setExpectation(_mock) {
mock = _mock;
}
function createClient() {
return client;
}
module.exports = {
createClient,
setExpectation
}
const asyncRedis = require('async-redis');
describe('something', () => {
it('test', async () => {
asyncRedis.setExpectation({ success: true });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment