Skip to content


Subversion checkout URL

You can clone with
Download ZIP
JavaScript testing plugin
Ruby JavaScript
Pull request Compare This branch is 26 commits ahead of rails:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


=JavaScript testing plugin

This plugin provides the JavaScript unit testing framework
in a way that integrates with Rails applications.


Use the provided generator to built a skeleton for your JavaScript test.
The built-in rake task can then be used to automatically run the unit tests
in various installed browsers (supported are Firefox on IE/Mac/Linux, 
Safari, WebKit on Mac, Konqueror on Linux).

Note that due to the built-in webrick, you don't have to change anything
about your app, just add tests. :)


Generate a JavaScript test skeleton for your public/javascripts/foo.js file:

  script/generate javascript_test foo

Run the unit tests (an "assertTruth" dummy test is provided,
so you should see "SUCCESS" messages), and see the automagically 
controlled browsers in action:

  rake test:javascripts
You can also run the test manually, by symlinking the assets directory.
In your Rails application root, run:

  ln -s ../../vendor/plugins/javascript_test/assets/ test/javascript/assets
You then can just open the individual .html test files in your browser.

All in all, unittest.js is closely modelled on Test::Unit. You can find lots 
of examples in both the Prototype and SVN repositories.

You'll find more info on how to write tests on the wiki:
The documentation there is not really complete, so feel free to help out.


Join the Rails Spinoffs Google Group, or ask on #prototype on


Big thanks with sugar on the top to Jon Tirsen, who authored the automated
browser remote control-gadgetry.


* Some more docs and a presentation :)

== License

Copyright (c) 2005-2008 Thomas Fuchs, released under the MIT license
Something went wrong with that request. Please try again.