Allow custom stub implementation after initial stubbing #169

glenjamin opened this Issue Aug 3, 2012 · 2 comments


None yet

3 participants


You can do this:

this.sinon.stub(object, 'method', function() { return 'MyOwnComplexThing'; })

But you can't do this:

var stub = this.sinon.stub(object, 'method');
stub.runs(function() { return 'MyOwnComplexThing'; })

It's been two years, I am closing this.

@mroderick mroderick closed this Aug 12, 2014

I think this would be helpful in order to supply custom function for mock re: #12 (comment)

Since implementing this for .returns would be a breaking change (for existing code that returned literal functions), then an alternative could be provided (like .runs).

@mroderick mroderick locked and limited conversation to collaborators May 19, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.