咕噜+噶测试运行失败,"的ReferenceError:模块没有定义" [英] Grunt + Karma test runner fails with "ReferenceError: module is not defined"

查看:131
本文介绍了咕噜+噶测试运行失败,"的ReferenceError:模块没有定义"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过咕噜运行我们的测试噶,执行失败,出现以下错误:

When running our Karma test through Grunt, the execution fails with the following error:

[2013-12-30 10:14:22.690] [ERROR] config - Invalid config file!
[ReferenceError: module is not defined]

Gruntfile.js 卡玛配置看起来理智,我从另外一个项目,它工作得很好复制它。同为 karma.conf.js 文件,还有其他的项目,它工作正常的一个没有任何区别。

The Karma configuration in Gruntfile.js looks sane, I've copied it from another project, where it works just fine. Same for the karma.conf.js file, there's no difference to one of the other projects, where it works fine.

我看了一下这个问题,但它并没有与固定的问题有所帮助:<一href=\"http://stackoverflow.com/questions/13334749/testing-service-in-angular-returns-module-is-not-defined\">Testing在角返回模块服务不

I've had a look at this question, but it didn't help with fixing the issue: Testing service in Angular returns module is not defined

我不粘贴咕噜或噶配置文件,因为他们并没有对解决这个问题的任何影响。

I'm not pasting the Grunt or Karma config files since they didn't have any impact on fixing this issue.

推荐答案

有关此问题的解决方案是在这里找到:的 https://github.com/karma-runner/grunt-karma/issues/52

The solution for this issue was found here: https://github.com/karma-runner/grunt-karma/issues/52

基本上,一个旧版本的咕噜 - 卡玛模块作为一个的开发依赖的,在这种情况下,它是版本的 0.4.3 的 - 这里是从的package.json 文件中的片段:

Basically, an old version of the grunt-karma module was used as a dev dependency, in this case it was version 0.4.3 - here's a snippet from the package.json file:

{
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-copy": "~0.4.1",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-uglify": "~0.2.5",
    "grunt-karma": "~0.4.3",
    "matchdep": "~0.1.2",
    "karma": "~0.10.2",
    "karma-coverage": "~0.1.0",
    "karma-script-launcher": "~0.1.0",
    "karma-firefox-launcher": "~0.1.0",
    "karma-chrome-launcher": "~0.1.0",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-jasmine": "~0.1.3",
    "karma-requirejs": "~0.1.0",
    "karma-coffee-preprocessor": "~0.1.0",
    "karma-phantomjs-launcher": "~0.1.0",
    "karma-junit-reporter": "~0.1.0"
  },

  // ...
}

显然,咕噜 - 卡玛这个旧版本导致了模块没有定义错误。

Apparently, this older version of grunt-karma is causing the module is not defined error.

更新此使用较新的版本( 0.6.2 的,这是我们在工作正常的其他项目中使用),解决了这个问题:

Updating this to use a more recent version (0.6.2, which we use in the other project that's working fine) solved the issue:

"grunt-karma": "~0.6.2"

然后运行 NPM安装在项目目录下载咕噜 - 卡玛的更新版本,并且测试跑之后的罚款。

Then running npm install in the project directory downloaded the updated version of grunt-karma, and the tests ran fine after that.

这篇关于咕噜+噶测试运行失败,&QUOT;的ReferenceError:模块没有定义&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆