Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Rockett
40,365 PointsHow do you go about testing express routes?
I understand how you would test an API where json is returned with the res object, but I don't understand how you could test anything when you need to render a template like res.render.
I've looked at loads of tutorials online but all the examples involve returning json, which you can't do if your returning a template
Any help with this would be greatly appreciated Thanks, Mike
1 Answer
Tom Geraghty
24,174 PointsFrom the docs, response.render()
Renders a view and sends the rendered HTML string to the client.
What does the rest of your test suite look like? You should be able to take the HTML string that is returned by res.render and inspect it for something that makes your tests pass.