2
我想測試簡單的代碼:Webstorm UT - 找不到模塊
function div2(a, b) {
return a/b;
}
module.exports.div = div2;
而且在examplesTestUnit.js文件:
var calculator = require("./examples");
module.exports["div test"] = function(test) {
test.equal(calculator.div(6,2), 3);
test.equal(calculator.div(12,0), Infinity);
test.equal(calculator.div(0,3), 0);
test.done();
};
當我嘗試在Webstorm運行測試我的錯誤:
/usr/bin/node /tmp/nodeunit-intellij-starter.js /usr/lib/node_modules/nodeunit examplesTestUnit.js
Testing started at 02:42 ...
module.js:340
throw err;
^
Error: Cannot find module '/usr/lib/node_modules/nodeunit/deps/async'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at resolveAsyncModule (/tmp/nodeunit-intellij-starter.js:304:20)
at testIt (/tmp/nodeunit-intellij-starter.js:308:21)
at run (/tmp/nodeunit-intellij-starter.js:335:9)
at Object.<anonymous> (/tmp/nodeunit-intellij-starter.js:365:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Process finished with exit code 8
我安裝摩卡做檢查和摩卡didnt給我一個錯誤,但仍然沒有結果:
[[email protected] untitled]$ mocha examplesTestUnit.js
0 passing (1ms)
[[email protected] untitled]$
我已經在0.8.6版本中安裝nodeunit,我已經嘗試重新安裝。 加上其他錯誤我在終端recive:
[[email protected] untitled]$ nodeunit --
/usr/lib/node_modules/nodeunit/lib/nodeunit.js:72
if (err) throw err;
^
Error: ENOENT, stat '/home/DzikiChrzan/WebstormProjects/untitled/--'
我使用的Fedora 22
我該如何解決這個問題?