本文介紹了嘗試使用 jasmine 和 angular 時出錯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
當我嘗試使用 $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 時出錯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!