Quando ho aggiornato angolare percorso 1.5.0 a 1.5.1, ho un errore:Karma errore quando update angolare percorso 1.5.0 a 1.5.1
angolare Unit Test: Errore: richiesta imprevisto: GET
Quando lancio il karma, ho un messaggio di errore:
1) Call getAll method [App Category] Error: Unexpected request: GET http://myapp.com/app-category?is_active=true No more request expected in /node_modules/angular-mocks/angular-mocks.js
app_category.model.test.js
describe('[App Category]', function() {
beforeEach(module('myApp'));
var $httpBackend, HttpService, AppCategory;
beforeEach(inject(function (_$httpBackend_, _HttpService_, _AppCategory_) {
$httpBackend = _$httpBackend_;
HttpService = _HttpService_;
AppCategory = _AppCategory_;
}));
it('Call getAll method', function() {
var app_category = new AppCategory();
HttpService.mock('GET', 'app-category?is_active=true', 200, [{ code: 'TRAVEL', name: 'Travel' }]);
app_category.getAll({ is_active: true }).then(function (request) {
expect(request.data[0].code).toBe('TRAVEL');
expect(request.data[0].name).toBe('Travel');
});
$httpBackend.flush();
});
});
angolare-m ockHTTP.js
(function (angular) {
'use strict';
angular.module('ngMockHTTP', []).service('HttpService', function ($httpBackend, config) {
this.endpoint = config.api.endpoint;
this.mock = function (method, url, status, response) {
switch (method) {
case 'GET':
$httpBackend
.expectGET(this.endpoint + url)
.respond(status, response);
break;
case 'POST':
$httpBackend
.expectPOST(this.endpoint + url)
.respond(status, response);
break;
case 'PUT':
$httpBackend
.expectPUT(this.endpoint + url)
.respond(status, response);
break;
case 'PATCH':
$httpBackend
.expectPATCH(this.endpoint + url)
.respond(status, response);
break;
case 'DELETE':
$httpBackend
.expectDELETE(this.endpoint + url)
.respond(status, response);
break;
}
};
});
})(angular);
ho cercato di REMPLACE:
case 'GET':
$httpBackend
.expectGET(this.endpoint + url)
.respond(status, response);
break;
da questo:
case 'GET':
$httpBackend
.whenGET(this.endpoint + url, {
}).respond(function(){ return [200, response]});
break;
Ma io ho lo stesso errore
Io uso gelsomino 2.4.1, angularjs 1.5.3, karma 0.13.0
Stesso problema qui. Non l'ho capito, quindi ho eseguito nuovamente il downgrade a 1.5.0. – cgcladera
Lo stesso problema qui con 1.5.1 e 1.5.3. Downgrade a 1.5.0 ... – lucassp
Angular Route 1.5.1, 1.5.2 e 1.5.3 ... stesso problema ... –