Get error when try to use jasmine and angular

折月煮酒 提交于 2019-12-19 05:44:50

问题


When I try to use $httpBackend.flush(); I get error TypeError: $browser.cookies is not a function. I can't find any information about this kind of error and any solutions.

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
    });
});
  • Angular: 1.3.15
  • Jasmine: 2.3.4

回答1:


I believe you are using the angular mocks for version 1.4.x, and your code is using angular 1.3.15. Please check that you are using the mocks for the version you are implementing in your application. Also it is always good to provide your jasmine test configuration file.



来源:https://stackoverflow.com/questions/30487943/get-error-when-try-to-use-jasmine-and-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!