无法在摩卡中解析路径 [英] Cannot resolve path in Mocha
问题描述
我目前正在使用Nitrous,这应该不重要,但我需要安装mocha,所以我输入:
I am currently using Nitrous, which shouldn't matter, but I needed to install mocha so I typed in:
npm install - g mocha.
一切安装完毕,当我尝试在命令行中运行mocha时,我收到以下错误:
Everything installed and when I try to run mocha in my command line I get the following error:
/home/action/.parts/lib/node_modules/mocha/bin/_mocha:454
if(!files .length)抛出新错误(无法解析路径(或模式)
/home/action/.parts/lib/node_modules/mocha/bin/_mocha:454
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
错误:无法解析路径(或模式)'test / unit'
b $ b在lookupFiles(/home/action/.parts/lib/node_modules/mocha/bin/_mocha:454:32)
at runAgain(/home/action/.parts/lib/node_modules/ mocha / bin / _mocha:305:24)
在Array.forEach(native)
at Object。(/ home / action / .parts / lib / node_modules / mocha / bin / _mocha:304:6)
在Module._compile(module.js:456:26)
at Object.Module._extensions..js(module.js:474: 10)
在Module.load(module.js:356:32)
在Function.Module._load(module.js:312:12)
在Function.Module.runMain(module.js:497:10)
启动时
(node.js:119:16)
node.js上的
:902:3
Error: cannot resolve path (or pattern) 'test/unit'
at lookupFiles (/home/action/.parts/lib/node_modules/mocha/bin/_mocha:454:32)
at runAgain (/home/action/.parts/lib/node_modules/mocha/bin/_mocha:305:24)
at Array.forEach (native)
at Object. (/home/action/.parts/lib/node_modules/mocha/bin/_mocha:304:6)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
有谁知道如何解决这个问题?
Does anyone know how to solve this?
推荐答案
默认情况下,mocha包含 ./ test / *。JS
。因此,如果这是您的测试所在,只需运行 mocha
即可。
By default, mocha includes ./test/*.js
. So if that is where your tests live, just running mocha
is all you need.
如果您有测试在 test / unit
中,您可能想要运行 mocha ./test/unit/*.js
.
If you have your tests in test/unit
, you might want to run mocha ./test/unit/*.js
.
这篇关于无法在摩卡中解析路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!