Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs $httpBackend';量角器试验无反应_Angularjs_Protractor_Httpbackend - Fatal编程技术网

Angularjs $httpBackend';量角器试验无反应

Angularjs $httpBackend';量角器试验无反应,angularjs,protractor,httpbackend,Angularjs,Protractor,Httpbackend,我正在尝试用Gragrator/Jasmine编写一个测试,这取决于我是否能够看到HTTP请求中发送的头。为此,我正在尝试使用$httpBackend创建一个模拟端点,它将使用头本身响应调用,从而允许我在测试中查看它们。我的代码如下: describe('Headers', function () { it('should include X-XSRF-TOKEN on HTTP calls', function () { browser.addMockModule('h

我正在尝试用Gragrator/Jasmine编写一个测试,这取决于我是否能够看到HTTP请求中发送的头。为此,我正在尝试使用$httpBackend创建一个模拟端点,它将使用头本身响应调用,从而允许我在测试中查看它们。我的代码如下:

describe('Headers', function () {
    it('should include X-XSRF-TOKEN on HTTP calls', function () {
        browser.addMockModule('httpBackendMock', function () {
            angular.module('httpBackendMock', ['CorsApp', 'ngMockE2E'])
            .run(function ($httpBackend) {
                $httpBackend.whenGET('/xsrftest')
                    .respond(function (method, url, data, headers) {
                        return headers;
                    });
            })
        });

        loginPage.get();

        browser.executeAsyncScript(function (callback) {
            var $http = angular.injector(['ng']).get('$http');

            $http.get('/xsrftest')
                .then(function (response) {
                    callback(response);
                });
        })
        .then(function (response) {
            console.log(response);
        });
    });
});
我试图遵循许多参考资料中列出的模式,在量角器测试中使用$httpBackend。然而,当我运行这个测试时,我得到了一个量角器超时。似乎$http.get调用从未收到响应,因此从未调用回调,因此executeAsyncScript调用超时。如果我对不依赖于$http.get的回调函数进行伪调用,它将按预期工作

设置$httpBackend时我做错了什么?如何让它响应我的$http请求

谢谢