Which is the best way to intentionally add latency to db.collection.save() for unit testing purposes.
Let say, I have function that I need to test:
function() {
let item = collection.findOne({});
...
collection.save(item);
}
I would like collection.save to be delayed without changing the function code.
Basically I'm looking for something like this express pause middleware but for MongoDB driver.