It looks like at the moment you cannot ONLY modify .js scripts to include $ httpBackend in a mockery. You will need to add another code to support it.
For me, the best way is the following
Add myAppTest.js to the test folder, which includes "ngMockE2E", so you do not need to foul the existing app.js
'use strict'; angular.module('myAppTest', ['myApp', 'ngMockE2E']) .run(function($httpBackend) { var user = {name: 'Sandra'}; $httpBackend.whenGET('/api/user').respond(user); });
Then add a separate test-index.html that uses the new myAppTest.js. Note that you need to enable angular -mocks.js. (This leaves your html production file intact and does not contain ridicule)
<!doctype html> <html lang="en" ng-app="myAppTest"> <head> <script src="lib/angular/angular.js"></script> <script src="lib/angular/angular-resource.js"></script> <script src="../test/lib/angular/angular-mocks.js"></script> <script src="js/app.js"></script> <script src="js/controllers.js"></script> <script src="../test/e2e/myAppTest.js"></script> </head> <body> <div ng-view></div> </body> </html>
Then in your .js script, just reference your new test-index.html before running other tests.
beforeEach(function() { browser().navigateTo('../../app/test-index.html#/'); });
I adapted this example:
https://github.com/stephennancekivell/angular_e2e_http/tree/ngMockE2E
source share