javascript - AngularJS Unit Test: Module 'admin.module' is not available -


i'm testing angular controller using karma , jasmine can't seem load in module main class.

here's main class: admin.controller.js

angular.module('admin.module').controller('admin.controller', ['$scope', function ($scope) { $scope.savechanges = function() {     return true; } }]); 

here's test class: admin.controller.tests.js

describe('admin.controller tests', function () {      beforeeach(module('admin.module'));     var $controller = {};      beforeeach(inject(function (_$controller_) {         $controller = _$controller_;     }));      describe('$scope.savechanges', function () {         it('should return true', function () {             var $scope = {};             var controller = $controller('admin.controller', { $scope: $scope });             expect($scope.savechanges()).tobe(true);         });     }); }); 

my karma.conf.js file points following files in project:

// list of files / patterns load in browser files: [   '../triangular/scripts/angular.js',   '../triangular/scripts/angular-mocks.js',   '../triangular/app/admin/*.js',   'app/admin/*.js' ], 

the admin.controller.js file inside ../triangular/app/admin , admin.controller.test.js inside 'app/admin'.

i have tried directly reference files in karma config file has not worked. full error is:

module 'admin.module' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument.

the issue turned out not exception being shown. missing angular-route.js file needed included looked admin module dependent on it.

list of includes in karma.conf.js file:

// list of files / patterns load in browser files: [   '../triangular/scripts/angular.js',   '../triangular/scripts/angular-mocks.js',   '../triangular/scripts/angular-route.js',   '../triangular/app/admin/*.js',   'app/admin/*.js' ], 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -