Tuesday, 2 May 2017

Properly stubbing request/response with Sinon/Mocha

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});
   } 
}



via cusejuice

No comments:

Post a Comment