Introduction
The idea for this book started with a series of blog posts I wrote some time ago exploring building a Backbone.js app using tests. I initially wanted to just consolidate these blog posts into a book, however once I started jotting down what I wanted to put into this series, I decided there was more to write about.
In the Front end and JavaScript world we have come a long way since the heady days of table based layouts sprinkled with Macromedia roll over scripts to make web pages interactive. The lines between back end and front end application code has almost blurred completely, you could argue it no longer exists when you consider Isomorpic apps. Our tooling has changed substantially as well: at our disposal we have package managers (for both back and front end), build tools, unit test frameworks and deployment tools.
Conventions
Before we get started here are few conventions to be aware of. Where ever you see a statement like below starting with > this is a command you type from the terminal window
1 > menaing a command typed at the console
Whereas as the following typicallys is code or a configuration to be added to a file:
1 code
2 or
3 config
What we will be building
Over the coming pages and posts we will explore how to build a web app guided by tests, using a toolset that will allow you to deploy with each commit to the cloud. We’ll making use of JavaScript across the whole stack to build a small weather app using forecast.io’s API. The app itself will use the browser’s Geolocation API to figure out where your user is and retrieve a weekly weather forecast for that location.
How we will build it
Plain and simple, we’ll build this app guided by tests, using a continuous delivery model and have it deployed using Codeship’s CD service to a Heroku instance.
The focus of this book is really about setting you on the right path to delivering quality software reliably and continuously. By the end you should have the confidence to push every commit to ‘production’.
We will be making extensive use of the following tools:
- Node.js
- Grunt
- Karma
- Jasmine
- Cucumber
- Selenium
What you will need
There are few pre-requisits you will need to get this app built. You will need to sign up for some services, grab a code/etxt editor, set up a version control system and finally get your Node.js environment configured.
Services you wil need to sign up for
As I mentioned for our weather forecast API, we’ll be using forecast.io, so you might want to go and sign up for a developer account as you will need a key to access the API.
You should also sign up for a Github or Bitbucket account if you don’t already have one, we’ll need this for version control and our CI service.
So that we can reliably deploy our app, we’ll make use of Codeship’s hosted Continuous Integration service. Sign up for the free service to get started.
To host our app we’ll make use of Heroku’s cloud computing service. They also offer a free service to help you get started.
That should cover the things you need to sign up for.
Code editor
You will need a decent IDE (I recommend WebStorm) or Text Editor (Sublime is very popular with many of my co-workers).
Cloud9’s browser based editor (though calling it just an editor, is doing it a bit of a disservice) Is another option I can recommend.
Version control: Git
Using Version Control for every project is a must, regardless of size or complexity. If you don’t already have Git installed you should do so. There are many ways to install the necessary binaries and the Git website has all the necessary links. If you are on a Mac though, then I would recommend using Homebrew to install the binaries.
If you are new to Git then I recommend taking the Git Immersion guided tour.
Node.js and NPM
We’ll be making extensive use of JavaScript and various libraries throughout the book, so you will need to install Node.js and NPM. Once again if you are on a Mac though, then I would recommend using Homebrew to install the binaries.
NPM will allow us to resolve all of the dependencies we need in order to achieve our goal of building and delivering a web app guided by tests.
Bower
Bower is handy tool to manage your front end library dependencies, so I recommed installing it as well.
Grunt
Grunt will be our build and automation tool. If you haven’t used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins.
With all that installed and configured, it’s time to get started!