If you write unit test for your angularjs application you may already read the documentation provided by the angularjs website. It has a lot of good information but i missed the description of how to test services that i wrote for my application. For angularjs services the jasmine setup code looks like:
beforeEach(inject(function(_$controller_){
$controller = _$controller_;
}));
The _$controller_ is an internal representation of the angularjs controller service, $controller is a local variable.
So, how does injecting of a custom service work? Well, it is easy...
beforeEach(inject(function(_YourService_){
$localService = _YourService_;
}));
And the service code:
yourAppServices.factory('YourService', [function($http, ESCommons) {
return {...}]);
No comments:
Post a Comment