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({\"
I use promises with Mongoose and stub the methods like this:
const stub = sinon.stub(YourModel, 'findById').returns({ populate: sinon.stub().resolves(document) })
Then I can call it like:
const document = await YourModel.findById.populate('whatever');