Skip to content
Painless Javascript testing for Rails 3.1
Ruby JavaScript CoffeeScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This gem provides sane defaults for using Javascript test frameworks in the Rails 3.1 Asset Pipeline. It allows you to write and run Qunit or Jasmine tests while leveraging the new compiling power of Tilt and Sprockets 2. Now enabling more profit when you write your JS tests in CoffeeScript!

How it works

TestTrack is a mountable engine whichs provides routes to Javascript test runners pre-loaded with your application's code and tests. In addition to the test runners, Sinon.js is included for mocking, spies, and XHR faking. It's usage is entirely optional and won't affect pre-existing test suites.


In your Rails 3.1 app, just add it to your Gemfile, like this:

gem "test_track"

Then create a manifest file named qunit.js or jasmine.js which requires all of your test code for its respective suite, including any custom helpers.

// SUITE :: Jasmine
// SUITE MANIFEST :: spec/javascripts/jasmine.js
// TEST SRC DIR :: spec/javascripts
//= require helpers/spec_helper
//= require profile_spec
//= require user_spec

TestTrack automatically adds test paths to your app's asset pipeline. The default locations are...

  • Jasmine - spec/javascripts
  • Qunit - test/javascripts

We would recommend that you place your test manifests in these directories and will look for them there by default. Feel free to place these anywhere else in the asset pipeline, just don't forget to specify its location in an initializer. If it happens to be in the root of an asset directory, no additional configuration is required.

If you'd like to change a default, such as the name of your Jasmine manifest, try the following in config/initializers/test_track.rb:

TestTrack.setup do |config|
  config.qunit_manifest = "test/qunit"

To see this in action, check out the sample Rails code in test/dummy. See lib/test_track.rb for all available options.

Finally, just mount the TestTrack engine in routes.rb.

mount TestTrack::Engine => "test"

And you're off the the races. An index is provide with links to the test runners. They would be accessible at /test/jasmine and /test/qunit in the example above.


Obviously, you may not want to have these routes available if your app is running in :production. Give this a try!

mount TestTrack::Engine => "test" unless Rails.env.production?


This project uses the MIT-LICENSE.

Something went wrong with that request. Please try again.