node.js functional testing and deployment with zombie and codeship

An automated deployment system that runs a set of tests reviewing site functionality against a real system before pushing to live environments provides real peace of mind.

Using the zombie testing framework allow fast execution via jsdom of headless browser interactions. The speed which these tests execute is important, getting a quick greenlight on all site functionality with every push to master allows me to iterate quickly and with confidence.

Functional Testing with zombie

The zombie.js docs are excellent but they default to having you point to an external domain. This process requires you to run everything on the temporary test server so include preliminary app setup at the beginning of the test file.

var app = express();  
// ... etc.
const Browser = require('zombie');  

Then fire up the server in a before block wrapping all test descriptions.

describe('server', function () {  
  before(function (done) {
    var myroutes = require('../src/routes');
    app.use('/', myroutes);
// ... etc.

Then run the tests setting browser.proxy directly to local site instance.

  describe('login', function(){    

    const browser = new Browser();

    browser.proxy = 'http://localhost:'+port;

    before(function(done) {
      browser.visit('/ambassador/login', done);

    describe('submits form', function() {

      before(function(done) {
          .fill('userid',    '***')
          .fill('password', '***')
          .pressButton('Login', done);

      it('should be successful', function() {

      it('should see welcome page', function() {
        browser.assert.text('title', 'Ambassador dashboard');

    after(function() {



Codeship is a really nice service for running an on demand continuous integration server. It easily integrates into your git workflow, spins up on demand servers to your specifications to run your tests and triggers deployments. In order to run tests I have a set of setup commands configured in codeship

nvm use iojs  
npm install  

And a single test command to run after setup


If you put your codeship account's key on your production systems you can trigger deployments. The following commands take a zipped copy of the site from the temporarily spun up codeship ubuntu instance and copy it to my target server, then trigger my deploy script on that box

cd ..  
tar -cvf website.tar ~/clone/*  
# Deploy to test server
scp -P 2212 -rp website.tar **@****:/home/**/website.tar  
ssh -p 2212 **@**** "sudo ./myDeployScript.sh"  

My deploy script does stuff like replace files, run the local npm install, clear my nginx cache and restart the service. My node process is daemonized using upstart via (https://www.npmjs.com/package/upstart) so I just sudo service myProcess restart it.