Trying to get started with defining tests for my angular app, but feeling a bit lost as it's my first time working with testing.
I'm specifically interested in setting up Tests with Jasmine for REST Services within my application. My main question is how I can effectively test the GET requests. I've looked at examples on the jasmine site, but they only show how to check if the URL is correct.
What I really want to do is verify that I am actually receiving response data. Is this achievable? Additionally, the Angular documentation suggests using $httpBackend for $resource, which has added to my confusion about getting started with writing these tests.
Starting with my services:
resService
:
testApp.factory('ResService', ['$resource', 'baseUrl',
function ($resource, baseUrl) {
return {
group: $resource(baseUrl + '/api/qr_group/:Id', {
Id: '@Id'
}, {})
}
}]);
CrudService
:
...
getAllGroups: function () {
return ResService.group.query();
},
And finally, my Controller with the request:
TestCtrl
:
CrudService.getAllGroups().$promise.then(
function (response) { $scope.groups = response; },
function (error) { errMessage(error); }
);
If anyone has any suggestions or ideas, it would be greatly appreciated :)