出现错误时尝试使用茉莉花和角 [英] Get error when try to use jasmine and angular

查看:144
本文介绍了出现错误时尝试使用茉莉花和角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 $ httpBackend.flush(); 我得到错误的类型错误:$ browser.cookies不是一个函数我无法找到这种类型的错误和任何解决方案的任何信息。

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
    });
});


  • 角:1.3.15

  • 茉莉花:2.3.4

  • 推荐答案

    我相信你正在使用的角度嘲笑为版本 1.4.X ,和你的code是采用了棱角分明 1.3.15 。请检查您正在使用你的应用程序正在执行的版本嘲笑。此外,它是一件好事,提供您茉莉测试配置文件。

    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.

    这篇关于出现错误时尝试使用茉莉花和角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆