Tag: 达摩卡中华

当使用mocha + sinontestingExpressJS路线时,如何“存根”一个本地path的函数?

所以在一个文件中,我定义了这个路由: router.post('/', security.authenticate, function(req, res, next) { //Doing prep stuff //Do database work (<< this is what im really testing for) //Calling another work function. createFormUser(req.body, (ret) => { return res.json(ret.createdUser); }); }); 其次是这个function: var createFormUser = (ourUser, call) => { // does a bunch of misc work and creation for another database // unrelated […]