I get how to stub Mongoose models (thanks to Stubbing a Mongoose model with Sinon), but I don\'t quite understand how to stub calls like:
myModel.findOne({\"
Another way is to stub or spy the prototype functions of the created Query (using sinon):
const mongoose = require('mongoose');
sinon.spy(mongoose.Query.prototype, 'where');
sinon.spy(mongoose.Query.prototype, 'equals');
const query_result = [];
sinon.stub(mongoose.Query.prototype, 'exec').yieldsAsync(null, query_result);