gulp task can't find karma.conf.js

好久不见. 提交于 2019-12-05 02:16:34

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.

If another destination directory is assigned to __dirname, then it doesn't work. Try this:

var Server = require('karma').Server
gulp.task('test', function (done) {
   new Server({
     configFile: require('path').resolve('karma.conf.js'),
     singleRun: true
   }, done).start();
 });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!