我只是在用Mocha学习Unit.js。我正在执行以下步骤:http://unitjs.com/guide/quickstart.html。我已经安装了摩卡,并且正在运行“ example.js”脚本。脚本失败
$摩卡example.js
0通过(1ms)
使用-full-trace运行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运行它。并在以下目录中运行:/ home / rball / test
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”的任何路径。
我想念什么?
谢谢你的帮助
最佳答案
我认为您需要在“ -full-trace”之前加一个“-”。
示例:“-full-trace”
您使用'test.string(example)'设置断言。您已经为它传递了指定的变量类型,如果您正在验证字符串值,长度等,那就很好了。
尝试以下方法:
'test.value(example).isString();'
- - 要么 - -
'test.value(example).must.be.a.string();'
http://unitjs.com/api/value.html#isString
关于javascript - Unit.js,Mocha example.js失败0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39478273/