Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Michael Rockett40,321 Points
How 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
Tom Geraghty24,162 Points
From 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.