Mockgoose: how to simulate a error in mongoose?
I ended up stubing mongoose.createConnection
(so the generator) to return a object which call the error.
let stub = { mongoose: { createConnection: () => { return { on: (eventName, callback) => { if(eventName === 'error') { callback('Medical Error'); } }, once: () => {} } } } }, medical = proxyquire('./../medical.js', { 'mongoose': stub.mongoose });