10

当我尝试使用$httpBackend.flush(); 我收到错误TypeError: $browser.cookies is not a function。我找不到有关此类错误和任何解决方案的任何信息。

describe("someText", function() {
    var $httpBackend;
    var someManager;
    var authRequestHandler;

    var dataMockup = [];

    beforeEach(function(){
        module('app');

        inject(function($injector){
            $httpBackend = $injector.get('$httpBackend');
            someManager = $injector.get('someManager');

            authRequestHandler = $httpBackend.when('GET', 'someUrl.php')
                .respond(dataMockup);
        });
    });

    it('test first action', function() {
        $httpBackend.expectGET('someUrl.php');
        messageManager.loadData();
        $httpBackend.flush(); // There i got error
    });
});
  • 角度:1.3.15
  • 茉莉花:2.3.4
4

1 回答 1

18

我相信您正在使用版本的角度模拟1.4.x,并且您的代码正在使用角度1.3.15。请检查您是否正在为您在应用程序中实现的版本使用模拟。此外,最好提供您的 jasmine 测试配置文件。

于 2015-05-27T16:20:26.710 回答