2016-09-13 66 views
0

我剛剛學習與摩卡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」的路徑。

我錯過了什麼?

感謝您的幫助

+0

你不應該'要求(」 ../ node_modules/unit.js')'。由於它是一個項目依賴項,只需要'require('unit.js')' –

回答

-1

我認爲你需要一個額外的「 - 」中「 - 全追蹤」的前面。

例如: '--full追蹤'

你設置爲 'test.string(例如)' 你的聲明者。你已經通過它指定的變量類型,如果你正在驗證字符串值,長度等,那很好。

試試這個: 'test.value(example).isString();' ----或---- 'test.value(example).must.be.a.string();'

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

+0

真的需要鏈接嗎? – dorukayhan