Testing Services in Angular.js

Tuesday, January 13th, 2015

Getting started with unit testing your Angular code can be tricky due to setting up your test runner, learning some of the conventions, and figuring out how dependency injection works with your tests. One of the first things you will probably want to test are your services. There are two ways to inject services into your unit tests.

Read More

Jasmine vs. Mocha, Chai, and Sinon

Monday, January 12th, 2015

This article was updated on 4/15/15 to reflect Jasmine 2.x and updated again on 1/2/16

Read More

Maintainable Language Translations in JavaScript Templates and Backbone Views

Friday, January 9th, 2015

There are many things that you need to consider when writing JavaScript for an international site. Things such as formatting currency, dates and times, and translating almost every piece of text on the site. If you don’t create an extensible approach, it can easily become a mess to maintain and update when new countries are introduced. In this post I wanted to go over a really simple and maintainable approach that I have been using to translate all text in my JavaScript templates. I’ll first show an example using client-templating by itself and then I’ll show how to create a Backbone.View that abstracts this away for you.

Read More

An Approach to View-Models in Backbone

Wednesday, January 7th, 2015

One of the difficult parts I am experiencing when working with Backbone is separating out display logic properties from models. Let’s look at a simple example where we display a user model in a view and allow the user’s email address to be edited.

Read More

5 Reasons Why A Backbone Developer Loves Ember

Tuesday, January 6th, 2015

Last year I started a new job as where I am currently tasked with rebuilding an ecommerce site for the company. The JavaScript stack is using Backbone, Lodash, Handlebars, Zepto, Require.js, and CoffeeScript. I had played with Backbone when it first came out and used it for small things but this has definitely been my biggest Backbone project. Prior to this job I had been using a lot of Angular. As I learned more and more about Backbone, I kept missing some of the features and structure Angular had. So I thought to myself, maybe I am doing something wrong. I went on to read Building Backbone Plugins by Derick Bailey, looked at Marionette.js, and incorporated several of those ideas into our own abstractions. This definitely helped remove some of the boilerplate code since Backbone is really minimalistic. Even with these abstractions, certain things felt wrong and messy. At that point, I decided to learn Ember just to hopefully learn and borrow some new concepts despite knowing that Ember was something we wouldn’t use for this project. So here is my list of 5 things that I learned and borrowed from Ember for Backbone.

Read More