jeudi 15 septembre 2016

Grtting Error: $injector:modulerr Module Error while unit testing in angular js

I am trying to write unit test case with angular and jasmine. I am getting the following error when running the tests:



var BCM = angular.module("App", ['ui.router','ngAnimate','ui.bootstrap','ngAria','ngTable','ngSanitize','jcs-autoValidate','toaster', 'googlechart'])
.config( [ "$stateProvider","$urlRouterProvider","$controllerProvider","$provide","$compileProvider", function($stateProvider, $urlRouterProvider,$controllerProvider,$provide,$compileProvider) {

    $urlRouterProvider.otherwise("/")
    $stateProvider
    .state('login',{
        url: "/",
        templateUrl: "media/views/login/login.html",
        resolve :{
            deps: BCM.resolveScriptDeps(['media/js/app/modules/login/model/login-model.js','media/js/app/modules/login/controllers/login-controller.js'])
        },
        controller  : 'loginController'
    })
}]);




/**
 * Test cases for app-loader
 */

    'use strict';
    describe('caseInvestigation', function () {
      var $state, $stateParams, $q, $templateCache, $location, $rootScope,$injector,getAllCase,getNewCase,getOwnCase,getResolvedCase;
      beforeEach(function(){
            angular.mock.module('ui.router');
            angular.mock.module('ngAnimate');
            angular.mock.module('ui.bootstrap');
            angular.mock.module('ngAria');
            angular.mock.module('ngTable');
            angular.mock.module('ngSanitize');
            angular.mock.module('jcs-autoValidate');
            angular.mock.module('toaster');
            angular.mock.module('googlechart');
            module('caseInvetigation')
    });
      beforeEach(inject(function(_$state_, _$stateParams_, _$q_, _$templateCache_, _$location_, _$rootScope_){
            $state = _$state_;
            $stateParams = _$stateParams_;
            $q = _$q_;
            $templateCache = _$templateCache_;
            $location = _$location_;
            $rootScope = _$rootScope_;
            spyOn('$state','go');
            $templateCache.put('media/views/login/login.html','');

      }));
    //Test whether our state activates correctly
      it('should activate the state', function() {
          $state.go('login');
          $rootScope.$digest();
          expect($state.current.name).toBe('login');
      });


    });

Error...

debug.html:38 Error: [$injector:modulerr] http://ift.tt/2cWZx1z)
    at Error (native)
    at http://localhost:9876/base/js/lib/angular/angular.min.js:6:416
    at http://localhost:9876/base/js/lib/angular/angular.min.js:40:60
    at n (http://localhost:9876/base/js/lib/angular/angular.min.js:7:355)
    at g (http://localhost:9876/base/js/lib/angular/angular.min.js:39:135)
    at Object.fb [as injector] (http://localhost:9876/base/js/lib/angular/angular.min.js:43:164)
    at Object.workFn (http://localhost:9876/base/js/lib/angular/angular-mocks.js:2799:52)window.__karma__.result @ debug.html:38KarmaReporter.specDone @ adapter.js:243dispatch @ jasmine.js:2026(anonymous function) @ jasmine.js:2000specResultCallback @ jasmine.js:927complete @ jasmine.js:376clearStack @ jasmine.js:673QueueRunner.run @ jasmine.js:1932QueueRunner.execute @ jasmine.js:1910queueRunnerFactory @ jasmine.js:710Spec.execute @ jasmine.js:367fn @ jasmine.js:2561attemptAsync @ jasmine.js:1967QueueRunner.run @ jasmine.js:1922QueueRunner.execute @ jasmine.js:1910queueRunnerFactory @ jasmine.js:710fn @ jasmine.js:2546attemptAsync @ jasmine.js:1967QueueRunner.run @ jasmine.js:1922QueueRunner.execute @ jasmine.js:1910queueRunnerFactory @ jasmine.js:710TreeProcessor.execute @ jasmine.js:2408Env.execute @ jasmine.js:772(anonymous function) @ adapter.js:322loaded @ debug.html:42(anonymous function) @ debug.html:140
debug.html:38 TypeError: Cannot read property 'go' of undefined
    at Object. (app-loader-test.js:32)

Aucun commentaire:

Enregistrer un commentaire