2014-03-19 3 views
1

업보 내에서 서비스를 테스트하려고합니다. 서비스가 테스트에로드되고 있지만 http 요청은 무시됩니다.카르마는 서비스중인 각형 HTTP 요청을 무시합니다.

서비스에는 다음이 포함

console.log('test') //this is shown withing the karma console 

$http.get("myjson.json").then(function(data) { 
     this.data = data.data; 
}); // this isn't executed 

테스트 :

describe("Testing http request in service.", function() { 
    beforeEach(module('myAPP')); 

    var service, gHttp; 

    beforeEach(inject(function($injector,$rootScope , $httpBackend, myService) { 
     service = myService; 
     gHttp = $httpBackend; 
    })); 

    it('should work', function() { 
    gHttp.flush(); 
    //Error: No pending request to flush ! 
    }); 
}); 

답변

0

당신은 gHttp.expectGET('myjson.json')

로 먼저 $httpBackend 기대를 설정해야
관련 문제