Mock a class method using mockery and sinon
问题 I'm learning to unit test using the node module mockery with sinon. Using only mockery and a plain class I'm able to inject a mock successfully. However I would like to inject a sinon stub instead of a plain class but I'm having a lot of troubles with this. The class I am trying to mock: function LdapAuth(options) {} // The function that I want to mock. LdapAuth.prototype.authenticate = function (username, password, callback) {} And here is the code I'm currently using in my beforeEach()