2016-09-13 4 views
0

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"が含まれているパスが認識されていないため、フルトレース出力のエラーは困惑しています。

私には何が欠けていますか?あなたの助け

+0

あなたは ''(」../ node_modules/unit.js')を要求すべきではありません。それはプロジェクトの依存関係なので、単に 'require( 'unit.js')'を実行してください。 –

答えて

-1

ため

おかげで私はあなたが余分に必要だと思う「 - 」「-fullトレース」の前で。

例: '--full-トレース'

あなたは 'test.string(例)' で、あなたのアサーションを設定します。文字列の値、長さなどを検証する場合は、既に指定した変数の型を渡しています。

代わりにこれを試してみてください:'test.value(例).isString();' ----または---- 'test.value(例).must.be.a.string();'

http://unitjs.com/api/value.html#isString

+0

最後のリンクは本当に必要ですか? – dorukayhan

関連する問題