我正在尝试配置mocha来运行测试,而不是使用以下命令手动运行:
node_modules\.bin\mocha -w
我收到如下错误。
D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\mocha\lib\utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) '-w'
at Object.lookupFiles (D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\moc
at D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\mocha\bin\_mocha:316:30
at Array.forEach (native)
at Object.<anonymous> (D:\Downloads\Bluemix\dw0015a\dw0015a\node_modules\moc
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
答案 0 :(得分:0)
我能够获得类似于您所报告的行为,以w
选项前面加上&#34; en dash&#34;字符(Unicode U+2013)而不是减号。像这样:
$ mocha –w
/home/x/local/lib/node_modules/mocha/lib/utils.js:626
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) '–w'
at Object.lookupFiles (/home/x/local/lib/node_modules/mocha/lib/utils.js:626:15)
[... etc ...]
确保使用减号(十六进制值0x2d)。