Reputation: 167
when running my e2e tests i setup fixtures like this in a bootstrap file:
var myApp = angular.module('myApp', [dependencies]);
var appTest = angular.module('appTest', ['myApp', 'ngMockE2E']);
appTest.run(function($httpBackend) {
$httpBackend.whenGET('/api/products').respond(someResponseObject);
});
then a have separated files for each the scenarios i want to test. How can I setup the $httpBackend and fixtures inside the scenarios files (thus, potentially have different setups) instead of in a single bootstrap file? It tends to get long and unreadable.
Thanks.
Upvotes: 2
Views: 155
Reputation: 81
You can inject $httpBackend to your specs in scenario files, like below:
http = undefined
beforeEach inject(function($httpBackend){
http = $httpBackend
});
And setup the fixture as required in scenario files like below:
beforeEach(function() {
http.whenGET('/api/products').respond(someResponseObject);
});
Upvotes: 2