2016-08-18 49 views
0

我使用業力測試我的角應用程序中的控制器,應用程序它自我運作如預期,但單元測試拋出error: unexpected request: GET views/home.html 因爲我得到的問題是由ui路由器和$ httpBackend。這樣一種方法是通過緩存「卡瑪 - 預處理」,但我所做的是:意外GET請求在業力單元測試

var MenuController, scope, $httpBackend; 
// Initialize the controller and a mock scope 
beforeEach(inject(function($controller, _$httpBackend_, $rootScope, menuService) { 
// place here mocked dependencies 
$httpBackend = _$httpBackend_; 
$httpBackend.whenGET("views/header.html").respond(200,''); 
$httpBackend.expectGET("http://localhost:3000/dishes").respond([{ .... 

但得到錯誤顯示了我的意見的文件夾每個模板。

現在有沒有辦法忽略所有的模板和任何其他意外的GET請求?

回答

0

您可以創建的所有模板匹配的請求正則表達式: httpBackend.whenGET(/views\/.*\.html/).respond(200, {});或僅 httpBackend.whenGET(/views\//).respond(200, {})