admin管理员组文章数量:1296886
I'm relatively new to unit-testing on the backend and need some guidance as to how to unit-test the following. I'm using Mocha/Should/Sinon.
exports.get = function(req, res) {
if (req.query.example) {
return res.status(200).json({ success: true });
} else {
return res.status(400).json({error: true});
}
}
I'm relatively new to unit-testing on the backend and need some guidance as to how to unit-test the following. I'm using Mocha/Should/Sinon.
exports.get = function(req, res) {
if (req.query.example) {
return res.status(200).json({ success: true });
} else {
return res.status(400).json({error: true});
}
}
Share
Improve this question
edited May 2, 2017 at 13:56
cusejuice
asked May 2, 2017 at 13:41
cusejuicecusejuice
10.7k27 gold badges95 silver badges150 bronze badges
4
- are you using the “expect” or “should” syntax of chai? – Patrick Hund Commented May 2, 2017 at 14:38
- Using the should syntax of chai – cusejuice Commented May 2, 2017 at 14:48
-
Aaah… OK, I'll update my answer then
本文标签: javascriptProperly stubbing requestresponse with SinonMochaStack Overflow
版权声明:本文标题:javascript - Properly stubbing requestresponse with SinonMocha - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741642523a2390000.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论