用化合物js和mocha测试节点js

时间:2013-05-09 21:56:59

标签: node.js nodeunit compoundjs

我使用以下方法从头创建了scaffolded compoundjs app:

compound init test_app && cd test_app

compound g crud user id name password created:date

npm test

运行:./ node_modules / .bin / mocha --include test / init.js test / / .test.js

但是,我只收到以下输出错误:

> test_app@0.0.1 test /home/ubuntu/test_app
  

./ node_modules / .bin / mocha --include test / init.js test / / .test.js

✖ 1 of 10 tests failed:

1) UserController "before each" hook:
 ReferenceError: getApp is not defined
  at Context.<anonymous> (/home/ubuntu/test_app/test/controllers/users_controller.test.js:16:11)
  at Hook.Runnable.run (/home/ubuntu/test_app/node_modules/mocha/lib/runnable.js:196:15)
  at next (/home/ubuntu/test_app/node_modules/mocha/lib/runner.js:243:10)
  at Object._onImmediate (/home/ubuntu/test_app/node_modules/mocha/lib/runner.js:254:5)
  at processImmediate [as _immediateCallback] (timers.js:317:15)


npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

1 个答案:

答案 0 :(得分:3)

使用mocha解决了问题:

mocha test/*