Karma basePath默认为C:\

Hal*_*ton 3 javascript karma-runner karma-jasmine gulp

我试图通过业力运行jasmine Specs但是当karma查找我包含的文件时,它使用了一个基本路径,C:\即使配置文件在C:\dev\project\.

我在吞咽任务中运行Karma:

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

与此问题相关的设置:

basePath: '',
files: [
 {patterns:'bower_components/**/*.js',included:true},
 {patterns:'src/*.js', included:true},
 {patterns:'tests/*Spec.js', included:true}
],
exclude: []
Run Code Online (Sandbox Code Playgroud)

当我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.
Run Code Online (Sandbox Code Playgroud)

我是业力新手,我不确定这里的问题是什么.我试过basePath'','./''/'.

Ste*_*acy 6

使用以下命令将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: []
Run Code Online (Sandbox Code Playgroud)

process.cwd() 获取CLI路径,即终端中节点运行的路径.