Stubbing and/or mocking a class in sinon.js?
问题 I've created a database wrapper for my application, shown below. To test it, I obviously would like to replace the actual database library. I could create a new class that mocks the query method and catch all input there, but using sinon.js seems more appropriate, but how would I use it? Is the mock or stub features of sinon.js what I should be using? wrapper = (function() { function wrapper() {} wrapper.db = require("database"); wrapper.prototype.insertUser = function(doc) { return this.db