lundi 27 juin 2016

Ionic app unit test error - TypeError: undefined is not an object

I'm unit testing my ionic hybrid app. First time I'm doing unit test & by following this article - http://ift.tt/1AVd5xY

My controller.tests.js code is

describe('LoginController', function(){
    var scope;

    // load the controller's module
    beforeEach(module('e2pro.LoginController'));

    beforeEach(inject(function($rootScope, $LoginController) {
        scope = $rootScope.$new();
        $controller('LoginController', {$scope: scope});
    }));

    // tests start here
    it('should have enabled friends to be true', function(){
        expect(scope.foo).toEqual(true);
    });
});

My LoginController.js file is

angular.module('e2pro.LoginController', [])

// Employee Attendance Controller
.controller('LoginController', function($http, $scope, $state, $ionicHistory, $ionicLoading){
    console.log('Inside Login Controller');

    $scope.foo = true;

});

When I'm running this command karma start tests/my.conf.js I'm getting following error in my terminal.

enter image description here

Any idea where I'm doing wrong ?

Aucun commentaire:

Enregistrer un commentaire