Click here to Skip to main content
Click here to Skip to main content

AngularJS Unit Testing on Amazon Elastic Bamboo Instance

, 6 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
How to setup unit test environment on Amazon Elastic Bamboo instance

Background

I'm working on greenfield SPA web application based on AngularJS. The beauty of this framework is the ability to cover almost every aspect of your application with unit tests. And it is really easy to start if you use boilerplates such as angular-seed which provides unit test core you have to extend with your real tests.

Local setup on Windows laptop was completed in a few minutes: clone angular-seed, run npm to install necessary packages and check karma unit test runner is working and sample tests are green. Although you can have a few small issues related to PATH variables, it doesn't take significant time to fix them and continue.

Then it was a turn of server environment to be set up. I'm not a Linux person and in that moment, even didn't know what kind of Linux is installed there. The only thing I had was SSH access. I have checked that node, npm, karma commands are not recognized and started installation process. After many trials and errors, I stuck on a step of installing of browser (tried both Chrome and Firefox) which is vital for karma unit test runner. There was a dependency on absent GTK+ libraries and I finally gave up with this approach.

But then I found two important things: headless browser PhantomJS which is supported by karma and node which was already installed on the server but not registered anywhere. So I've got clean instance and made following steps which gave me working environment at the end.

Commands

Lookup for installed node which gave me /opt/node-0.10/:

find / -name node -print 2>/dev/null 

Link node and npm binaries:

cd /usr/bin 
sudo ln -s /opt/node-0.10/bin/node
sudo ln -s /opt/node-0.10/bin/npm 

Install necessary npm modules (I prefer global deployment):

sudo npm install karma -g 
sudo npm install phantomjs -g
sudo npm install karma-jasmine -g
sudo npm install karma-spec-reporter -g 
sudo npm install karma-phantomjs-launcher -g 

Link karma binary:

sudo ln -s /opt/node-0.10/lib/node_modules/karma/bin/karma 

Modify karma configuration in karma.conf.js from angular-seed to use PhantomJS browser:

browsers: ['PhantomJS'], 
plugins: [ 
    'karma-spec-reporter', 
    'karma-phantomjs-launcher', 
    'karma-jasmine' 
] 

And if everything above ended up correctly, the following script from angular-seed should report successful execution of your unit tests (script below was a part of the previous version of angular-seed, now tests are executed using npm and configuration from package.json):

bash /scripts/test.sh 

Points of Interest

This should be a good start for those who never had much Linux/AWS/Bamboo experience but have to setup continuous integration environments in the same server configuration.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mike114
Software Developer (Senior) Beam Technology
Australia Australia
No Biography provided
Follow on   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150129.1 | Last Updated 6 Apr 2014
Article Copyright 2014 by Mike114
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid