gpt4 book ai didi

javascript - Karma basePath 默认为 C :\

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:47:12 24 4
gpt4 key购买 nike

我正在尝试通过 karma 运行 jasmine Specs,但是当 karma 查找我包含的文件时,它使用 C:\ 的基本路径,即使配置文件位于 C:\dev\项目\

我在 gulp 任务中运行 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 时,来自 karma 的日志显示如下:

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.

我是 karma 的新手,不太确定这里的问题是什么。我尝试了 '''./''/'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路径,即终端运行的节点路径。

关于javascript - Karma basePath 默认为 C :\,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24047413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com