Skip to content

Instantly share code, notes, and snippets.

@davelnewton
Last active August 20, 2016 14:44
Show Gist options
  • Save davelnewton/a2b786fd485b6767606bcb20942c4616 to your computer and use it in GitHub Desktop.
Save davelnewton/a2b786fd485b6767606bcb20942c4616 to your computer and use it in GitHub Desktop.
const sinon = require('sinon')
function Example() {}
Example.prototype.someFunc1 = function () { return 42; }
Example.prototype.func = function (fn) { return fn(); }
const example = new Example()
console.log(example.func(example.someFunc1))
// >> 42
sinon.stub(example, 'someFunc1').returns(69);
console.log(example.func(example.someFunc1))
// >> 69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment