我刚刚学习与摩卡Unit.js。我遵循以下步骤:http://unitjs.com/guide/quickstart.html。我已经安装了摩卡,并且正在运行“example.js”脚本。与Unit.js,摩卡example.js失败0传递
$摩卡example.js
0传递(1毫秒)
与-full追踪我得到运行example.js脚本失败:
$摩卡example.js - 全迹
C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\lib\utils.js:652
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) '-t'
at Object.lookupFiles (C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\lib\utils.js:652:15)
at C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:326:30
at Array.forEach (native)
at Object.<anonymous> (C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:325:6)
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:134:18)
at node.js:961:3
我用cygwin64运行这个。并在目录中运行:/家庭/ rball /测试
的example.js是:
// load Unit.js module
var test = require('../node_modules/unit.js');
// just for example of tested value
var example = 'hello';
// assert that example variable is a string
test.string(example);
// or with Must.js
test.must(example).be.a.string();
// or with assert
的unit.js是在node_modules目录。
完整跟踪输出中的错误令人困惑,因为我不知道任何带有“-t”的路径。
我错过了什么?
感谢您的帮助
你不应该'要求(” ../ node_modules/unit.js')'。由于它是一个项目依赖项,只需要'require('unit.js')' –