user2072912
user2072912

Reputation: 275

How do I make my stubbed ajax calls live throughout my karma jasmine test cycle?

I have a backbone application where by instantiating one view, a whole chain of ajax calls get called. So if I have MainView.js and I instantiate it new MainView(), MainView instantiates IASModel.js which makes a request and returns a promise to MainView. Then, MainView instantiates TestCastModel.js and makes anther ajax call etc... If I were to test MainView.js, I would have to stub all these ajax calls (https://github.com/jasmine/jasmine-ajax). Then as my test progress, I would gradually have to programmatically create less of these ajax stubs, because my application is progressing.

How would I just have one file that lives throughout the lifecycle of all my tests? I want to be able to grab any ajax request, have that one file process it (route to appropriate path) and return the stub for that call.

Upvotes: 0

Views: 148

Answers (0)

Related Questions