mochaでUnit.jsを学習しています。私は以下のステップを踏んでいます:http://unitjs.com/guide/quickstart.html。私はmochaをインストールしていて、 "example.js"スクリプトを実行しています。 $モカは私が得る-fullトレースでexample.jsを実行する(1ミリ秒)Unit.js、Mocha example.jsに0が合格しません
渡し
0を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')'を実行してください。 –