I needed to stub out a Backbone collection’s fetch method and make it return success. I’m using Jasmine BDD for the testing framework and Sinon.js for stubbing the methods. Here’s how I did it:
I just wanted to say 2 years later and this is still helpful! It is exactly what I was looking for. Thanks!
Glad to hear it!
After you posted this, Sinon 1.4.0 added async versions of those function calls. So yieldsToAsync may be a better use for fetch.
This site uses Akismet to reduce spam. Learn how your comment data is processed.