Ho i seguenti test unitari e per qualche motivo il secondo test fa fallire altri test.AngularJS Test unità gelsomino
beforeEach(inject(function ($rootScope, _$httpBackend_, $controller, $location, mockedResource) {
scope = $rootScope.$new();
httpBackend = _$httpBackend_;
locationService = $location;
ctrlDependencies = {
$scope: scope,
resource: mockedResource,
}
var ctrl = $controller('myController', ctrlDependencies);
}));
it('should redirect to a new page', function() {
scope.pageRedirectFunction();
expect(locationService.path()).toBe('/newpage')
});
it('should delete an epic resource', function() {
httpBackend.expectGET('/api/v1/epic/1').respond({});
httpBackend.expectDELETE('/api/v1/epic/1').respond({});
// Run the deletion function
scope.deleteEpicResource()
httpBackend.flush() // This line seems to be the rebelious one
expect(scope.epicResources.length).toEqual(0)
})
sono riuscito a capire la linea che sembra causare gli errori, ed è la linea httpBackend.flush()
. Perché la funzione flush causa un comportamento strano?
L'errore effettivo che ricevo da eseguendo il comando karma start
nel terminale, è:
Delaying execution, these browsers are not ready: Chrome 29.0 ....
dopo un po 'di tempo, la sessione di Chrome si blocca poi.
Che errore hai avuto? Senza di questo nessuno può nemmeno immaginarlo. – zsong
Ovviamente! Che terribile errore. Aggiornamento con l'errore ora ... – Sneaksta
Cerca di aumentare il livello di log di Karma per eseguire il debug, per vedere cosa succede. – madhead