我刚刚用 mocha 学习 Unit.js。我正在按照以下步骤操作:http://unitjs.com/guide/quickstart.html 。我已经安装了 mocha 并正在运行“example.js”脚本。脚本失败并显示
$ Mocha 示例.js
0 通过(1 毫秒)
使用 -full-trace 运行 example.js 我得到:
$ mocha example.js -full-trace
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)”设置断言器。您已经向它传递了指定的变量类型,如果您要验证字符串值、长度等,那就没问题了。
试试这个: '测试.value(示例).isString();' - - 或者 - - 'test.value(example).must.be.a.string();'
关于javascript - Unit.js , Mocha example.js 失败 0 通过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39478273/