我收到一个错误---错误:[$ injector:nomod] http://errors.angularjs.org/1.3.15/$injector/nomod?p0=decisionTree当我在Webstorm中运行karma.cong.js时

时间:2015-05-29 21:38:33

标签: karma-runner webstorm

这是我的karma.conf.js文件

module.exports = function(config) {

  var configuration = {

  basePath : '',

  autoWatch : false,

  frameworks: ['jasmine'],

  files: [
    'bower_components/angular/angular.min.js',
    'bower_components/angular-mocks/angular-mocks.js',
    'bower_components/angular-resource/angular-resource.min.js',
    'bower_components/angular-animate/angular-animate.min.js',
    'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
    'bower_components/angular-cookies/angular-cookies.min.js',
    'bower_components/angular-sanitize/angular-sanitize.min.js',
    'bower_components/angular-touch/angular-touch.min.js',
    'bower_components/angular-ui-router/release/angular-ui-router.min.js',
    'src/app/**/*.js'
  ],

  ngHtml2JsPreprocessor: {
    stripPrefix: 'src/',
    moduleName: 'gulpAngular'
  },

  browsers : ['PhantomJS'],

  plugins : [
    'karma-phantomjs-launcher',
    'karma-jasmine',
    'karma-ng-html2js-preprocessor'
  ],

  preprocessors: {
    'src/**/*.html': ['ng-html2js']
  }
  };

  config.set(configuration);
};

我已经在今天整个下午的堆栈上搜索了这些问题,但我仍然无法获得任何解决方案。 我想知道谁能解决这个问题。

1 个答案:

答案 0 :(得分:0)

似乎在应用程序文件之前加载了您的规范,并且您的角度模块无法解析。请尝试更改' files'如下:

files: [
            'bower_components/jquery/dist/jquery.js',
            'bower_components/angular/angular.js',
            'bower_components/angular-animate/angular-animate.js',
            'bower_components/angular-cookies/angular-cookies.js',
            'bower_components/angular-touch/angular-touch.js',
            'bower_components/angular-sanitize/angular-sanitize.js',
            'bower_components/angular-resource/angular-resource.js',
            'bower_components/angular-ui-router/release/angular-ui-router.js',
            'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'src/app/index.js',
            'src/app/main/main.controller.js',
            'src/app/components/navbar/navbar.controller.js',
            'src/**/*.html',
            'src/**/*.spec.js',
            'src/**/*.mock.js'

        ],
以这种方式更改配置后,

karma测试运行正常