Geddyunit testing控制器

你如何testinggeddy控制器? 这是我想testing的一个例子。

var assert = require('assert') , tests , controller = geddy.controller.create('Users'); tests = { 'test user controller, add new user': function (next) { var user = User.create({username: 'hbinduni', password: 'MyPassword!', confirmPassword: 'MyPassword!', familyName: 'binduni', givenName: 'binduni', email: 'hbinduni@email.com'}); //need to unit test controller.add here //how to mock req, resp? controller.add(req, resp, user); assert.equal(out, null); next(); } }; module.exports = tests; 

我怎么做控制器方法的unit testing? 如何模拟请求和响应?

谢谢。

我通过为请求和响应创build模拟对象来解决这个问题,这个对象可能会或可能不适合您,具体取决于您首先依赖于这些对象的内容。

https://github.com/franksrevenge/geddy-unit-test-utilities