我正在尝试通过业力运行 Jasmine 规格,但是当业力查找我包含的文件时,即使配置文件在C:\中,它也会使用C:\dev\project\的基本路径。

我正在执行任务中的Karma:

var karma = require('karma').server;
gulp.task('test', function (done) {
    karma.start({configFile: '../../../karma.conf.js', singleRun: true}, done);
});

与该问题有关的设置:
basePath: '',
files: [
 {patterns:'bower_components/**/*.js',included:true},
 {patterns:'src/*.js', included:true},
 {patterns:'tests/*Spec.js', included:true}
],
exclude: []

当我运行gulp test时,来自业力的日志会吐出以下内容:
WARN [watcher]: Pattern "C:/bower_components/**/*.js" does not match any file.
WARN [watcher]: Pattern "C:/src/*.js" does not match any file.
WARN [watcher]: Pattern "C:/tests/*Spec.js" does not match any file.

我是因果报应的新手,因此不确定在这里出什么问题。我尝试了basePath'''./''/'

最佳答案

使用以下命令将basePath设置为本地CWD目录路径:

basePath: process.cwd(), //  this gets the path which gulp is running in terminal
files: [
 {patterns:'bower_components/**/*.js',included:true},
 {patterns:'src/*.js', included:true},
 {patterns:'tests/*Spec.js', included:true}
],
exclude: []
process.cwd()获取CLI路径,即终端中正在运行的节点的路径。

10-08 08:05