I have finished building a CRUD application with 20 tests passing. I am using EJS to render the views and now I am having a problem with my tests.
As a simple example let's say that I was checking to see that when a GET request is sent to '/' that a JSON would be sent like so res.json({message:'hello'}) so I could set up my tests in Mocha so that res.body.message equates to 'hello'.
However what if I wanted to render the index.ejs page instead of sending a JSON. So it would look like res.render('index',{message:'hello'}). How can I test res.render()? or more specifically how can I test the object passed to res.render()?
Help is much appreciated !!
Aucun commentaire:
Enregistrer un commentaire