Hello, I can't find any updated documentation/tutorials about unit testing a controller method: const read = (req, res) => { Entry.find({}, (err, entries) => { if (err) { throw new Error(err) } if (!entries || !entries.length) { return res.status(404).json({ status: 'fail', data: { errors: 'NOT_FOUND' } }) } return res.status(200).json({ status: 'success', data: { entries } }) }) }This is called with: router.route('/entries').get(entryController.read) How do I test that if I have an HTTP request to /entries entryController.read is called?How do I test the result of entryController.read ?At the moment I am using mocha + sinon + chai. Altough I didn't understand they role
Submitted May 04, 2017 at 10:04PM by ettzzi
No comments:
Post a Comment