whenGET不是函数,但是当我输出proxy
var时,我会看到函数是否存在
{ when: [Function],
whenGET: [Function],
whenPUT: [Function],
whenHEAD: [Function],
whenPOST: [Function],
whenDELETE: [Function],
whenPATCH: [Function],
whenJSONP: [Function],
context: {},
flush: [Function],
syncContext: [Function],
onLoad: [Getter]
}
规范
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);
});
});
});
我错过了/忽略了什么吗?
答案 0 :(得分:0)
在http-backend-proxy
模块中,您可以看到它需要ngMockE2E
依赖关系(第147行)。
对我来说,ngMockE2E
(角度内置模块)未通过angular-mocks.js
脚本加载。
答案 1 :(得分:0)
对于这一行:var HttpBackend = require('http-backend-proxy');
当你应该使用小写的'httpBackend'
时,你在那里使用大写的'H'