2013-02-07 38 views
0

我在這裏有一些問題。我試圖嘲笑我的一些HTTP請求到服務器,並通過其中的一些!當我調用passThrougth()時,拋出一個錯誤!

Error: Unexpected request: GET view/networks.html 
No more request expected 
    at Error (<anonymous>) 
    at $httpBackend (http://localhost:8080/js/lib/angular-mocks.js:887:9) 
    at $httpBackend (http://localhost:8080/js/lib/angular-mocks.js:880:11) 
    at sendReq (http://localhost:8080/js/lib/angular-scenario.js:18264:9) 
    at $http (http://localhost:8080/js/lib/angular-scenario.js:18055:17) 
    at Function.$get.$http.(anonymous function) [as get] (http://localhost:8080/js/lib/angular-scenario.js:18198:18) 
    at $get.$q.when.then.then.next.locals (http://localhost:8080/js/lib/angular-scenario.js:16605:34) 
    at deferred.promise.then.wrappedCallback (http://localhost:8080/js/lib/angular-scenario.js:16028:59) 
    at deferred.promise.then.wrappedCallback (http://localhost:8080/js/lib/angular-scenario.js:16028:59) 
    at ref.then (http://localhost:8080/js/lib/angular-scenario.js:16065:26) 

這裏是我跑

myAppDev.run(function ($httpBackend) { 
    $httpBackend.whenGET("view/networks.html").passThrough(); 
    $httpBackend.whenGET('/r/networkInterface').respond(networkInterfaces); 

}); 

什麼是我的配置問題?

任何方式,當我呼籲迴應(「有一些迴應」),我得到的結果是正確的。即$ httpBackEnd返回什麼是作出迴應!

回答

1

好吧,經過漫長而艱苦的鬥爭,這個問題很容易解決。

1更新到1.0.5 angularJS

在我的測試2 - 當我刪除了這行代碼的一切去完善我有這行代碼

myAppDev.config(function ($provide) { 
    $provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator); 
}); 

。然而,這是Vojta jina使用的東西in this fiddle.