错误:[$ injector:nomod]模块'ui.bootstrap'不可用!而Karma在网络风暴中运行

7 angularjs angular-ui-bootstrap karma-runner karma-jasmine

嗨我在运行karma测试运行时在webstorm中收到以下错误

Error: [$injector:nomod] Module 'ui.bootstrap', 'ui.unique' 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.
Run Code Online (Sandbox Code Playgroud)

我看着互联网,他们说检查依赖文件ui.bootstrap可能会错过这样.

但应用程序工作正常

而只在测试时显示此错误

在我的karma.conf.js中

files: [
            //angular files

            'app/js/vendor/angular/ui.bootstrap.js',
            'app/js/vendor/angular/ui.bootstrap-0.10.0.js',

            'app/js/vendor/angular/angular.js',
            'app/js/vendor/angular/angular-mocks-0.10.6.js',

            'app/js/app.js',
            'test/**/*Spec.js'
        ], 
Run Code Online (Sandbox Code Playgroud)

在我的模块声明中

var myApp = angular.module('myApp', ['ui.bootstrap']);
Run Code Online (Sandbox Code Playgroud)

能否请你帮忙 ??

dma*_*tro 6

ui.unique是一个模块来自angular-ui-utils.如果被使用,那必须包含在karma conf中并注入到app中.

var myApp = angular.module('myApp', ['ui.bootstrap', 'ui.utils']);
Run Code Online (Sandbox Code Playgroud)

或者,如果仅使用唯一模块,则可以专门注入ui.unique而不是注入ui.utils.