Get error when try to use jasmine and angular(尝试使用 jasmine 和 angular 时出错)
问题描述
当我尝试使用 $httpBackend.flush(); 时出现错误 TypeError: $browser.cookies is not a function.我找不到有关此类错误和任何解决方案的任何信息.
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
的角度模拟,而您的代码使用的是角度 1.3.15代码>.请检查您是否正在为您在应用程序中实现的版本使用模拟.此外,最好提供您的 jasmine 测试配置文件.
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.
这篇关于尝试使用 jasmine 和 angular 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:尝试使用 jasmine 和 angular 时出错


- 如何显示带有换行符的文本标签? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01