This is a starting place for those wanting to learn how to run headless Jasmine JavaScript tests locally and on Travis CI.
Once you're familiar with how it works, it should be easy to add to your own projects.
Project includes:
-
how to setup Jasmine gem
-
sample Jasmine layout, created via
jasmine init
-
tweak of Rakefile to use 'jasmine:ci' task by default (for Travis and other CI systems)
-
Travis CI integration via .travis.yml -- see Travis CI Getting Started
-
Clone this repository
-
Ruby should already be installed on your system. Or install via Homebrew (on OSX). Or use Ruby Version Manager (https://rvm.io) if you want to isolate these Ruby dependencies.
-
Make sure you're in the root of the repository (which contains the gem and rake files)
-
Install dependencies using bundler
# run 'gem install bundler' if you don't already have bundler bundle install
-
Run tests
bundle exec rake jasmine # for a local web server version at http://localhost:8888 bundle exec rake # for default headless CI version. See "How to run headless" below.
Headless CI requires additional dependencies.
If running on your own desktop, just install Firefox.
If running on a server:
-
a virtual framebuffer such as Xvfb
-
a headless DOM via such as
iceweasel on Ubuntu
(which is headless Firefox), PhantomJS, etc.
Travis CI has these dependencies installed (see .travis.yml file). If you're running your own CI server, you'll need to install these.
-
New to Jasmine? Take a Quick Tour. See also the "Matchers" reference (Jasmine's equivalent to asserts).
-
enjoyable to use and easy to pickup. BDD-styled tests have nice readability.
-
well supported, well maintained.
-
JavaScript platform agnostic -- works fine with the JS libraries you're already using (jQuery, Closure Library, require.js, etc).
-
popular in the industry. Used by Cordova/PhoneGap for example.
-
easy (easiest?) to run headless on server (via Jasmine Ruby Gem and a few dependencies).
-
has spies and mocks built-in. There's also the Sinon.js library.