This post introduces a new JavaScript testing library that works with Sinon.JS to vastly improve the speed of your integration tests and also improve the quality of some of your unit tests. When we are writing code for some kind of client (could be a website), we usually want to test the layer of the… Read More


At Staance Engineering, I have implemented some of our integrations with Facebook. We want to have automated tests that ensure that all our integration scenarios work as we want them to. This blog post describes how we do that using tools like Nock and Sinon.JS. The same techniques can be applied to most other types… Read More


I gave a talk yesterday at Mile High Agile 2015: A lot of applications these days have a substantial, if not a major, part written in JavaScript. And not only for the front-end part, as Node.js is gaining popularity on the back-end. You might already have started doing some unit testing for your JavaScript code,… Read More


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


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 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