5

嗨,我正在关注这个angular 教程,但是通过运行以下命令 test.bat。我收到此错误,可能不是很好。

“无法加载脚本,它没有注册!也许你缺少一些插件”

我遵循了本教程的所有步骤,我想我错过了插件。我在应用程序的根目录中有一个名为 node_modules 的文件夹,所有这些插件都在哪里

     karma
     karma-chrome-launcher
     karma-coffee-preprocessor
     karma-firefox-launcher
     karma-html2js-preprocessor
     karma-jasmine
     karma-junit-reporter
     karma-phantomjs-launcher
     karma-RequireJS
     karma-script-launcher

我的 karma.config

module.exports = function(config){

config.set({
basePath : '../',

files : [
  'app/lib/angular/angular.js',
  'app/lib/angular/angular-*.js',
  'test/lib/angular/angular-mocks.js',
  'app/js/**/*.js',
  'test/unit/**/*.js'
],

exclude: ['app/lib/angular/angular-scenario.js'],

autoWatch : true,

frameworks: ['jasmine'],

browsers : ['C:/Program Files/Google/Chrome/Application/chrome.exe'],

plugins : [
  'karma-junit-reporter',
  'karma-chrome-launcher',
  'karma-firefox-launcher',
  'karma-jasmine'
],

junitReporter : {
  outputFile: 'test_out/unit.xml',
  suite: 'unit'
}

})}

任何人都可以帮助我吗?

谢谢

4

1 回答 1

6

您需要将缺少的插件添加到 karma config plugins 部分:

plugins : [
  'karma-junit-reporter',
  'karma-chrome-launcher',
  'karma-firefox-launcher',
  'karma-jasmine'
],

或者干脆删除这个插件部分,业力将加载它找到的所有插件。(如果你没有太多插件也可以这样做)

编辑:

刚刚克隆并安装了测试项目。以下是已安装的依赖项:

karma                      
karma-html2js-preprocessor  
karma-phantomjs-launcher
karma-chrome-launcher      
karma-jasmine               
karma-requirejs
karma-coffee-preprocessor  
karma-junit-reporter        
karma-script-launcher
karma-firefox-launcher     
karma-ng-scenario           
phantomjs

在我看来,您没有安装 phantomjs。

于 2013-11-01T12:46:45.657 回答