javascript - How to load angular module before loading controller using RequireJs, Jasmine, Karma -


i'm trying write unit test angular app, using requirejs, jasmine, karma. @ moment error:

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

when run app, ok, problem occurs when run unit tests.

this "coremodules" code creates new angular module , load controllers:

define(['app/modules/core/controllerreferences'], function(references) {      var coremodule = angular.module('coremodule', []);      require(references, function() {         angular.bootstrap(document, ['coremodule']);     }); }); 

and here code of homecontroller:

define(['angular'], function() {      angular.module('coremodule')         .controller('homecontroller', function($scope) {             $scope.title = "hello world";     }); }); 

as mentioned earlier, i'm trying write simple unit test can't load 'homecontroller' because above error.

define(['coremodule','angularmocks', 'app/modules/core/controllers/homecontroller'], function() {     describe('homecontroller test.', function() {     }); }); 

i don't know why, because load 'coremodule' before 'homecontroller'. tried load 'homecontroller' require(['path/homecontroller'], function(){}), don't error callback function in require not called. add:

require(['coremodule'], function() {   console.log('load core module.'); }); 

to test-main.js initialize 'coremodule'.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -