尝试使用jasmine和angular时出错

gre*_*rco 9 javascript jasmine angularjs httpbackend

当我尝试使用$ httpBackend.flush(); 我得到错误TypeError:$ browser.cookies不是一个函数.我找不到有关此类错误和任何解决方案的任何信息.

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
    });
});
Run Code Online (Sandbox Code Playgroud)
  • Angular:1.3.15
  • 茉莉花:2.3.4

tax*_*ala 17

我相信你正在使用角度模拟版本1.4.x,你的代码使用角度1.3.15.请检查您是否正在使用您在应用程序中实现的版本的模拟.提供茉莉花测试配置文件总是好的.