Last time, we completed the scaffolding of our little web app.
This time, we'll make it actually do something - and perform a little refactoring along the way. I'll also talk a bit about more advanced features of mocha.
Showing posts with label requirejs. Show all posts
Showing posts with label requirejs. Show all posts
Thursday, 9 May 2013
Friday, 26 April 2013
Test Driven UI Development with Node, Mocha and RequireJs (part 2)
Last time, we set out a framework for doing test driven development with our front end code.
Now we're going to build on that scaffolding to create a simple web app, adding modules as necessary as we go.
Now we're going to build on that scaffolding to create a simple web app, adding modules as necessary as we go.
Tuesday, 23 April 2013
Test Driven UI Development with Node, Mocha and RequireJs
Test driven development, or TDD, is often held up as an ideal to aim for in unit testing. Its simple premise of write a test, pass the test, refactor the code - or red, green, refactor - leads to good coding habits.
But testing your front end javascript code is hard... just getting it into a position where you can test it at all is tricky, and following examples on the web will tie you in knots. Then there's yet another problem... dependency injection. With so many hurdles to jump, it is little wonder that many projects have a handful of fragile integration tests that leave you wondering whether the trouble was worth it.
I'm going to attempt to lay out a method by which front-end code can be readily unit tested, without needing a headless browser.
But testing your front end javascript code is hard... just getting it into a position where you can test it at all is tricky, and following examples on the web will tie you in knots. Then there's yet another problem... dependency injection. With so many hurdles to jump, it is little wonder that many projects have a handful of fragile integration tests that leave you wondering whether the trouble was worth it.
I'm going to attempt to lay out a method by which front-end code can be readily unit tested, without needing a headless browser.
Subscribe to:
Posts (Atom)