Using Angular's Protractor framework, I have the following test file:
storeItems.e2e.js:
'use strict';
describe('home test', function() {
beforeAll(function() {
browser.addMockModule('httpMocker', function() {
angular.module('httpMocker', ['ngMockE2E'])
.run(function($httpBackend) {
$httpBackend.whenGET('/authentication/').respond([{"access_token": "123","expires_in": 500}]);
})
})
})
var EC = protractor.ExpectedConditions;
it('should load page successfully', function() {
browser.get('/store');
});
Running the above as a test doesn't seem to log any errors. However, when the browser loads, the network indicates that the request's response hasn't changed. And based on debugging/logging attempts, the code doesn't evaluate past browser.addMockModule('httpMocker', function() {
Also, I'm using Angular 1.7 so I believe that addMockModule
should still be usable unlike v2+.