Introduction When starting a new front-end JavaScript project, we have a lot of decisions to make. The JavaScript ecosystem has grown explosively over the past couple of years with exciting new tools, libraries and frameworks appearing on a weekly basis. To illustrate, look at the TodoMVC site that showcases different MVC frameworks: 15 main frameworks… Read More


When writing unit tests for our front-end JavaScript code, we often need to specify fixtures: static pieces of data that give the context for the test. A fixture can be a piece of HTML that the JavaScript function under test can operate on. Or a piece of XML that we mock the server to return.… Read More


With all the different screen sizes on different types of devices the idea of responsive design has emerged. For example, responsive design allows us to display a menu horizontally when the screen is wide enough, like this: and vertically when the screen is too narrow, like this: Responsive design like this is typically accomplished with… Read More


A couple of weeks back I gave a presentation for one of my clients on how to introduce unit testing into a large code base. Here is the appetizer: Unit testing and test-driven development are practices that makes it easy and efficient to create well-structured and well-working code. However, many software projects didn’t create unit… Read More


I gave a talk together with Rob Myers at the Mile High Agile conference in Denver the other day. Here is the appetizer: Test-Driven Development (TDD) and Continuous Integration (CI) are far more common for back-end projects than they are for front-end JavaScript projects. But front-end projects benefit just as much from the rapid feedback… Read More


On our backlog, we have the usual columns: Planned, In Progress and Done. But before the Done column we have an extra column called Verify. Our backlog looks like this: When a feature has been fully developed and tested, we move it to Verify where the owner of that feature can verify that the feature… Read More


One of the questions I often receive from developers starting with unit testing, is how we can test private methods. Here is my perspective on that. There are several ways to approach it: 1) Make the method public. 2) Extract the private method to its own class where it can be public and therefor tested… Read More


On one of our projects we structure our front-end JavaScript code using RequireJS modules, ensuring predictable load ordering and better encapsulation. When writing unit tests for code that depends, directly or indirectly, on one or more other modules, we often want to mock some of those modules to make our unit tests more focused giving… Read More


Most JavaScript-based Model-View-Controller frameworks make it very easy to write unit tests for the Model, and reasonably easy to write unit tests for the Controller. However, writing unit tests for the View is often seen as more difficult. This is no different with AngularJS, where most guidelines argue for end-to-end testing to get good test… Read More


When running our automated tests, we sometimes need a running web server. A back-end example is when we write (integration) tests against our web service end-points. A front-end example is when we use the text-plugin for RequireJS to load HTML templates (https://github.com/requirejs/text#xhr-restrictions). We can have multiple build jobs running on our CI-server, which is useful… Read More