gpt4 book ai didi

angularjs - GET 不是函数时失败 : $httpBackend.

转载 作者:行者123 更新时间:2023-12-03 10:06:23 27 4
gpt4 key购买 nike

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);
});
});
});

我在这里错过/忽略了什么吗?

最佳答案

http-backend-proxy 模块,你可以看到它需要一个 ngMockE2E依赖(第 147 行)。

对我来说,您的 ngMockE2E ( Angular 内置模块)未通过 angular-mocks.js 加载脚本。

关于angularjs - GET 不是函数时失败 : $httpBackend.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35774188/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com