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);

});

私の設定の問題は何ですか?

とにかく、 response(" with some response ") を呼び出すと、正しい結果が得られます。つまり、$httpBackEnd は、応答に入れられたものを返します。

4

1 に答える 1

1

わかりました、長く厳しい戦いの後、問題は非常に簡単に解決できました。

1- angularJS 1.0.5 へのアップデート

2-私のテストでは、このコード行がありました

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

このコード行を削除すると、すべてが完璧になりました。ただし、これは、このフィドルでVojta jina が使用したものです。

于 2013-03-08T08:59:26.367 に答える