I am new to angular js and trying to unit testing on ngRoute, But Getting this error : TypeError: undefined is not an object (evaluating 'location.path').
Here is my code for Unit testing
describe('Testing angularJS Test Suite', function() {
var location, route, rootScope;
beforeEach(module('myApp'));
beforeEach(inject(
function( _$location_, _$route_, _$rootScope_ ) {
location = _$location_;
route = _$route_;
rootScope = _$rootScope_;
}));
describe('Registration route', function() {
beforeEach(inject(
function($httpBackend) {
$httpBackend.expectGET('views/registration.html')
.respond(200);
}));
it('should load the registration page on successful load of /registration', function() {
location.path('/registration');
rootScope.$digest();
expect(route.current.controller).toBe('RegistrationController')
});
});
})
Can anyone suggest me, Why I am getting this error. Thanks.