[英]Testing AngularJS Service with Jasmine throw an error with parsed.protocol
我正在嘗試測試一些經過修改的服務。 其中一些正在使用$ http服務,而其中只有一個正在填充未知的和無法理解的問題。
讓我揭露。
it('must reject the promise with an explanation if the required path is not found', function() {
$httpBackend.whenGET('http://localhost/testok').respond(function () {
return [200, mockedRemoteResponse, {}];
});
var promise = apiDataExtractor.extractRemoteData('ok', 'toto');
$httpBackend.flush();
});
通過Jasmine運行這段代碼,我們得到了:
我對附加的內容一無所知。 我嘗試更改注入順序,嘗試擦除並重寫測試,但這里缺少某些內容。
有人可以幫忙嗎?
您看到的錯誤可能是由於調用了$ http.get且URL未定義(您可能忘記了在apiDataExtractor.extractRemoteData中向$ http.get()提供參數?)
嘗試調試代碼,看看為$ http.get方法提供的參數是什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.