Error: $ httpBackend.whenGET is not a function

when GET is not a function, but when I output the proxy var I cleary, I see that the function is

 { when: [Function], whenGET: [Function], whenPUT: [Function], whenHEAD: [Function], whenPOST: [Function], whenDELETE: [Function], whenPATCH: [Function], whenJSONP: [Function], context: {}, flush: [Function], syncContext: [Function], onLoad: [Getter] } 

Range

 describe('Login', function () { var Injector = require('./helpers/injector'); var loginPage = require('./pageObjects/LoginPage.js'); var HttpBackend = require('http-backend-proxy'); var proxy = new HttpBackend(browser); var loginJsonStub, loginPost, URLbase; //projectsJsonStub; beforeEach(function () { browser.get('http://localhost:9001/#'); loginPost = {'Login': 'sjv', 'Password': 'password'}; var injector = new Injector(); injector.get('loginJson').then(function (result) { loginJsonStub = result; }); var injector = new Injector(); injector.get('URLbase').then(function (result) { URLbase = result; }); }); /* Login scenario */ describe('should succeed with correct credentials and proceed to projects page', function () { it('should redirect to answerset page immediately if only 1 project', function () { loginJsonStub.Response.Payload.User.ProjectAmountIndication = 1; proxy.whenGET(URLbase + 'authentication/login', loginPost).respond(200, loginJsonStub); //httpBackend.whenGET(URLbase + 'project/getprojectsbyuserhierarchical').respond(200, {}); //projectsJsonStub.one loginPage.userName.sendKeys('xx\\svijver'); loginPage.password.sendKeys('password'); loginPage.nextButton.click(); browser.getLocationAbsUrl(); expect(browser.getCurrentUrl()).toContain('answersets/1'); browser.sleep(2000); }); }); }); 

I do not see / do not notice something here?

+5
source share
2 answers

In the http-backend-proxy module, you can see that it needs the ngMockE2E dependency (line 147).

For me, your ngMockE2E (angular built-in module) is not loading via the angular-mocks.js script.

0
source

For this line: var HttpBackend = require ('http-backend-proxy');

You use uppercase "H" when you must use the lowercase "httpBackend"

0
source

Source: https://habr.com/ru/post/1244361/


All Articles