Don’t let your mocks lie to you!

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: Don’t let your mocks lie to you!

Super fast end-to-end tests

Automated end-to-end tests are often seen as a necessary evil. A common example is Selenium-based browser tests.

This kind of testing has many drawbacks:

They take a long time to run They require complicated setup They are fragile

But it doesn’t have to be like that!

In this talk I describe how we can write . . . → Read More: Super fast end-to-end tests

Extreme Programming – to the next level

Inspired by a blog post by Benji Weber on Modern Extreme Programming, tonight I am giving a presentation on these ideas. Find my slides below:

Extreme Programming – to the next-level from Lars Thorup . . . → Read More: Extreme Programming – to the next level

Testing Facebook integrations

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: Testing Facebook integrations

Advanced JavaScript Unit Testing

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: Advanced JavaScript Unit Testing

Unit test your service integration layer

One of the complaints I hear most often about unit testing, is that its focus is too narrow. For instance, when testing a JavaScript front-end, the unit tests will make assumptions about the contract with the back-end API, typically by mocking the HTTP requests in the unit tests for the API integration layer. But those . . . → Read More: Unit test your service integration layer

Inline test fixtures in JavaScript

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: Inline test fixtures in JavaScript

Unit testing CSS and responsive design

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 . . . → Read More: Unit testing CSS and responsive design

Unit testing legacy code

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: Unit testing legacy code

Test-Driven Development in JavaScript – step by step

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: Test-Driven Development in JavaScript – step by step