lundi 29 décembre 2014

Error in Unit testing help me to solve this

I got error in this testing can anyone sove this why this happen


describe('Controller: LoginCtrl', function () { beforeEach(function(){



var $httpBackend;
module("loginModule");
});

beforeEach(inject(function($controller, $rootScope, $location, $auth, $httpBackend) {
this.$location= $location;
this.$httpBackend=$httpBackend;
this.scope= $rootscope.$new();
this.redirect = spyOn($location,'path');

$controller('LoginCtrl',{
$scope: this.scope,
$location: $location,
auth: $auth

});

}));



describe("succesfully loggin in",function(){
it("should redirect you to home",function(){
//arrange
$httpBackend.expectPOST('/login',scope.login).respond(200);
//act
scope.login();
$httpBackend.flush();

//assertion
expect(this.redirect).toHaveBeenCalledWith('/login');
});

});


});


Error i got is



Error: [$injector:unpr] Unknown provider: $authProvider <- $auth
http://errors.angularjs.org/1.2.28/$injector/unpr?p0=%24authProvider%20%3C-%20%24auth
at C:/xampp/htdocs/app/bower_components/angular/angular.js:3801
at getService (C:/xampp/app/bower_components/angular/angular.js:3929


) at C:/xampp/htdocs/app/bower_components/angular/angular.js:3806 at getService (C:/xampp/htdocs/app/bower_components/angular/angular.js:3929 ) at invoke (C:/xampp/htdocs/app/bower_components/angular/angular.js:3956) at workFn (C:/xampp/htdocs/app/bower_components/angular-mocks/angular-mocks .js:2177)



undefined
ReferenceError: Can't find variable: $httpBackend
at C:/xampp/htdocs/test/spec/controllers/login.js:32


PhantomJS 1.9.8 (Windows 8): Executed 1 of 1 (1 FAILED) ERROR (0.02 secs / 0.021 secs) Warning: Task "karma:unit" failed. Use --force to continue.


Aucun commentaire:

Enregistrer un commentaire