Learn to unit test your javaScript code with Mocha and Chai

Tags:

Have you ever made some changes to your code, and later found it caused something else to break? I’m sure most of us have. This is almost inevitable, especially when you have a larger amount of code. One thing depends on another, and then changing it breaks something else as a result. But what if that didn’t happen? What if …

Getting started with npm and Browserify in a React project

Tags:

This is the second article in a series where we build a Slack-style chat app with React. So far, in the previous article, we’ve built a simple prototype. We want to start adding features to it – such as actually supporting multiple people chatting – but before we do that, let’s set up some tools. npm and Browserify are useful …

Learning React basics and building a basic application prototype

Tags:

This is the first part in a series of articles, where we’ll be using React to build a Slack-style chat application. In this article, we’ll start by building a basic prototype. We’ll start by learning about React components and JSX. While doing that, we’ll also look at the basics of building React applications.

Getting started with React the easy way

Tags:

There’s a lot of talk lately about how it’s hard to get started with JavaScript libraries like React. You need ES6, you need Babel, you need this, you need that. If all you want is to try a library, there’s tons of technobabble getting in your way, sometimes involving so many steps it’s easier to just go and do something …

Top 5 articles of 2015

Tags:

With one year gone again, here’s the top 5 content from 2015! What’s the difference between unit testing, TDD and BDD? Comparison of JavaScript Linting Tools (ESLint vs JSLint vs JSHint vs JSCS) How to unit test NodeJS HTTP requests? What are Unit Testing, Integration Testing and Functional Testing? Getting started with ECMAScript 6 In 2015 the site’s traffic more …

Why is fixing bugs so slow? (and how to make it faster)

Tags:

Have you ever wondered why sometimes fixing bugs seems to take much longer than it should? When you finally find the problem, it turns out all you need is one small change. Yet, it took a lot of time to find what’s going on. This happens to me more often than I’d like. On the other hand, when you’re writing …

Sinon.js best practices for spies, stubs and mocks

Tags:

Sinon is one of the most important tools for testing, as without it writing tests for more complex pieces of code such as Ajax, networking, databases, etc. would become difficult. In this article, I’ll show you the best practices for using Sinon, so you’ll be able to apply it to your own projects more easily. What are the differences between …

How to deal with promises in JavaScript unit tests?

Tags:

One of my readers, Richard, sent me an email asking about promises in tests. It’s difficult to figure out how to put together a complete testing setup for code that uses promises, as there are so many different alternatives and so little information. I wanted to help, so in this article, I’ll tell you exactly what to do when you …