How it works
1. Install the Test Track gem
In your Rails 3.1 app, just add it to your Gemfile, like this:
2. Create a Manfiest
TestTrack automatically adds test paths to your app's asset pipeline. The default locations are...
- Jasmine -
- Qunit -
This is a good place for your manfiest file for your framework of choice. Here is a sample Jasmine manifest, called
For Qunit, create
We would recommend that you place your test manifests in the directories listed above, as TestTrack 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.
3. Set up Initializers (optional)
If you'd like to change a default, such as the name of your Jasmine
manifest, try the following in
TestTrack.setup do |config| config.qunit_manifest = "test/qunit" end
To see this in action, check out the sample Rails code in
lib/test_track.rb for all available options.
4. Mount the TestTrack Engine
mount TestTrack::Engine => "test"
And you're off the the races. An index is provided with links to the test
runners. They would be accessible at
/test/qunit in the example above.
In addition to the test runners, Sinon.js is included by default. It's a great set of tooling for mocking, spies, and XHR faking. In general, Sinon.js will not affect any pre-existing test suites, but there are some gotcha's. Be sure to check the out the documentation if you haven't used it before.
Sinon overwrites Jasmine's spyOn implementation, so be sure to not include it if you plan on using that part of Jasmine.
In Sinon's default settings, setTimeout and setInterval are overwritten. To change this behavior you need to modify Sinon's config object before your tests run.
sinon.config.useFakeTimers = false;
To not include Sinon, add the following to your TestTrack initiailizer. ] config.include_sinon = false
Obviously, you may not want to have these routes available if your app
is running in
:production. Try this in your
mount TestTrack::Engine => "test" unless Rails.env.production?
This project uses the MIT-LICENSE.