获得"模块没有定义"使用咕嘟咕嘟运行业力测试时出错 [英] Getting "module not defined" error when using Gulp to run karma tests

查看:140
本文介绍了获得"模块没有定义"使用咕嘟咕嘟运行业力测试时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在从步兵移动吞掉。我有一个咕噜测试任务工作正常,但是当我尝试运行测试(使用一饮而尽 - 卡玛)我得到一个错误,指出的ReferenceError:找不到变量:模块

My team is working on moving from Grunt to Gulp. I have a Grunt test task that works fine, but when I try to run the tests (using gulp-karma) I get an error that says "ReferenceError: Can't find variable: module"

我用Google搜索,发现很多帖子说要检查我的角mocks.js文件的位置,它是在正确的空间(同一code我咕噜任务的确实的工作)。

I Googled and found a lot of posts saying to check the location of my angular-mocks.js file, and it's in the correct space (my Grunt task for the same code does work).

要验证它是不是在我的$ C $怪异c进行纺了一个新的角度哟应用程序,并能复制错误。

To verify that it wasn't something weird in my code a spun up a new yo angular app and was able to replicate the error.

我的猜测是,我缺少的配置值或步什么的。有什么建议?

My guess is that I'm missing a configuration value or a step or something. Any advice?

感谢。

推荐答案

当您运行一饮而尽测试,一饮而尽 - 卡玛在寻找文件中的 gulpfile.js ,而不是 karma.conf.js 为您所定义。记住,当你返回 gulp.src(测试),您传递所需的测试文件的数组传递

When you are running gulp tests, gulp-karma is looking for files within gulpfile.js, not karma.conf.js as you have defined. Remember, when you return gulp.src(tests), you are passing in the array of files needed for the tests to pass.

要解决您的问题,在你的 gulpfile.js ,更新您的测试阵列包括您的亭子文件,应用程序文件和测试文件:

To fix your problem, in your gulpfile.js, update your tests array to include your bower files, app files, and test files:

var tests = [
  'bower_components/angular/angular.js',
  'bower_components/angular-mocks/angular-mocks.js',
  'bower_components/angular-animate/angular-animate.js',
  'bower_components/angular-cookies/angular-cookies.js',
  'bower_components/angular-resource/angular-resource.js',
  'bower_components/angular-route/angular-route.js',
  'bower_components/angular-sanitize/angular-sanitize.js',
  'bower_components/angular-touch/angular-touch.js',
  'app/scripts/app.js',
  'app/scripts/**/*.js',
  'test/mock/**/*.js',
  'test/spec/**/*.js'
];

您可以删除文件阵列 karma.conf.js 因为他们不需要。

You can delete the files array in karma.conf.js as they are not needed.

(PS我也做出了app.js的引用作为应用程序/脚本/ ** / *。JS 将不会匹配app.js这需要加载在第一)

(p.s. I also made a reference to app.js as app/scripts/**/*.js would not have matched app.js which needs to be loaded in first)

这篇关于获得"模块没有定义"使用咕嘟咕嘟运行业力测试时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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