【发布时间】: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
【问题讨论】:
-
确保您也拥有正确版本的 Angular 模拟文件。 cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/…
-
@PSL,谢谢。我没注意到。
标签: javascript angularjs jasmine httpbackend