Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's also mocha: http://visionmedia.github.com/mocha/

Which has very similar syntax to RSpec.



Try writing tests for controllers with Mocha. It isn't as simple as one might think.


Can you elaborate? I feel that I've written tests for controllers with Mocha several times without much hassle. Maybe you and I are using the word "controller" slightly differently, or are controlling different things?


My apologies I wasn't too specific. I was meaning a controller through express. It's not as straightforward as you would expect with code buried throughout on how to set it up. This is a typical barrier for developers to not test as much.


Express doesn't even have controllers though -- just a routing mechanism.

If you set up your controllers so that they are independent from the routes, then they are just as easy to test.

It could be as simple as: app.get('/users/:id', userController.userPage). You can then test userController.userPage(req, res, next) instead of the route.


True, but in the case of the app I need to start a test server and such. Its those steps that aren't well documented and can cause confusion.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: