gulp任务找不到karma.conf.js [英] gulp task can't find karma.conf.js

查看:182
本文介绍了gulp任务找不到karma.conf.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过吞噬任务来运行业力测试。我使用 https://github.com/karma-runner/gulp-karma 和for某些原因gulp找不到我的karma.conf.js。该文件位于与gulp文件相同的文件夹中。项目的根源。不管我放什么路径,我都会得到相同的错误。文件./karma.conf.js不存在。我无法弄清楚如何正确的路径。

  gulp.task('tdd',function(done){
新服务器({
configFile:'karma.conf.js'
},done).start();
});


解决方案

这是我使用Gulp

  var karma = require('karma');这两个文件位于同一个根目录中。 

gulp.task('karma',function(done){
karma.server.start({
configFile:__dirname +'/karma.conf.js'
},done);
});

更新

如果您运行的是NODE.js,那么



NODE Explnation for __dirname链接


当前正在执行的脚本所在目录的名称。


如果您没有运行NODE.js,那么您可能需要的只是

  configFile:'/karma.conf.js'

但是如果你正在运行NODE然后使用第一个示例。


I am trying to run karma test via a gulp task. I use https://github.com/karma-runner/gulp-karma and for some reason gulp cannot locate my karma.conf.js. That file is located in the same folder as the gulpfile. The root of the project. No matter what path I put, I get the same error File ./karma.conf.js does not exist. I cannot figure out how to path it correctly. Here is the code for the gulp task.

gulp.task('tdd', function (done) {
  new Server({
    configFile: 'karma.conf.js'
  }, done).start();
});

解决方案

This is how I spool up karma using Gulp ( and both files are in the same root ).

var karma = require('karma');

gulp.task('karma', function (done) {
  karma.server.start({
    configFile: __dirname + '/karma.conf.js'
  }, done);
});

UPDATE

If you are running NODE.js then

NODE Explnation for __dirname link

"The name of the directory that the currently executing script resides in."

If you are not running NODE.js, then perhaps all you needed was

configFile: '/karma.conf.js'

But if you are running NODE then use the first example.

这篇关于gulp任务找不到karma.conf.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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