javascriptangularjschutzpah

Chutzpah unable to find imported angular library module


I recently brought this angular library to my project:

https://github.com/a5hik/angular-multi-select-tree

Everything works great with it besides my unit testing. I am getting this error when running my tests:

Module 'multi-select-tree' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Which puzzles me as I have added it to my chutzpah.json references (and confirmed the paths are correct many times) like so:

{ "Path": "../Scripts/Lib/ng-multi-select-tree/ng-multi-select-tree.js" },
{ "Path": "../Scripts/Lib/ng-multi-select-tree/ng-multi-select-tree.tpl.js" },

And have included it in my main app.js file. The commented out code allows for Chutzpah to find the library, however this breaks all functionality of it:

// work around for Chutzpah test discovery
//angular.module('multi-select-tree', []);
var authoring = angular.module('authoring', ['ms-content', 'portalCommon', 'ngFileUpload', 'ckeditor', 'ui.bootstrap', 'AdalAngular', 'ui.sortable', 'nvd3', 'multi-select-tree']).run(['$rootScope', function ($rootScope) {}]);

The thing I am noticing is how this library instantiates the module like so:

(function () {
    'use strict';
    var mainModule = angular.module('multi-select-tree');

They seem to instantiate the module and then set it to a variable. Coworkers of mine are implying that this may be the problem. Any ideas as to why Chutzpah is having a hard time finding this particular module?


Solution

  • This ended up having nothing to do with how my module was initialized. It turns out Chutzpah does like lambdas ('=>').