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 …
Sinon.js best practices for spies, stubs and mocks
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 …
AngularJS: Setting up parallel / sticky states with ui-router and ui-router-extras
The application I’m developing at work has many independent parts, which needed their own states. Think of a UI similar to Photoshop, WebStorm, or such – Every panel in the UI is self-contained and can be changed without affecting the others. The standard ui-router has no concept of parallel states. Everything must be modeled as a tree, which means a …
How to fix JavaScript errors more easily with Chrome’s debugger
Let’s face it: As developers, much of our time is spent fixing problems. No matter how hard I try, there’s always something that needs debugging. In the past, I would use console.log or alert. Just sprinkle them in my code, and hope that they give me enough information to fix the problem. If you’ve tried doing that, you know that …
Unit testing Ajax requests with Mocha
Ajax requests can easily go wrong. You can’t guarantee the connection and the server always work correctly. They are also often used to send user input to the server and back, so it’s vital the data is handled correctly. But testing them can be tricky. It’s asynchronous, and also a good unit test must be isolated, so how can we …
ESLint vs JSLint vs JSHint vs JSCS
I recently wrote about using ESLint to auto-detect bugs. But what makes ESLint the best tool for this job? There are three other popular JavaScript linters: JSLint JSHint JSCS What are their pros and cons? How do they compare against ESLint? Read the rest of this article
Detect problems in JavaScript automatically with ESLint
I’ve been programming JavaScript for 15 years or so, and I still keep making various silly mistakes – I type things wrong, I forget to rename everything, I forget to follow the coding styles… then I waste my time clicking around in the browser and feel like slapping myself. Thankfully tools like ESLint exist. ESLint helps by finding errors automatically, …
How to unit test NodeJS HTTP requests?
I have a nodejs app where I wanted to unit test some HTTP requests. Node usually makes things simple, so I expected this to be like that too… but I soon discovered that this was not the case at all. When unit testing, you don’t want HTTP requests to go out and affect the result. Instead you create a fake …
Strange JavaScript errors and how to fix them
JavaScript has some of the strangest errors. Undefined is not a function? Ugh. I wrote an article talking about JS errors and a guide on how to fix them on David Walsh’s blog, you should go check it out! JavaScript errors and how to fix them
ES6: What are the benefits of the new features in practice?
You’ve probably seen people talk about the features in JavaScript’s 6th edition, ES6, or ECMAScript 6. Promises, let keyword, iterators, etc. But why should you care? I certainly heard a lot about it, but I hadn’t looked into it because I wasn’t interested in theory, but rather the benefits I would get in my day to day work. Is it …