【问题标题】:Get error when try to use jasmine and angular尝试使用 jasmine 和 angular 时出错
【发布时间】:2015-08-16 02:48:03
【问题描述】:

当我尝试使用 $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

【问题讨论】:

标签: javascript angularjs jasmine httpbackend


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-08-04
    • 2021-11-12
    • 2020-07-23
    • 2022-01-04
    • 2020-11-23
    • 2021-08-11
    • 2020-06-16
    • 1970-01-01
    相关资源
    最近更新 更多