mdotterer/javascript_testing
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
This collection of files is useful for getting a Rails app up and running with headless JSSpec tests for your JavaScript files.
INSTALLING
- Unpack the contents of this repo to RAILS_ROOT/spec/javascripts
- Move test_jsspec.rake into RAILS_ROOT/lib/tasks
WRITING SPECS
- Create the file in RAILS_ROOT/spec/javascripts/your_name_spec.js (The filename should end in _spec.js)
- Write the specs directly in the file.
- To use html fixtures:
- Create an html file in RAILS_ROOT/spec/javascripts/fixtures/your_fixture_name.html that has the body of your sample html in it. (No html, or body tags please).
- Load that fixture in the before_each for your spec by using fixture("your_fixture_name");
- That fixture will then be available for both command line and compiled specs
RUNNING SPECS
- To run specs on the command line run rake spec:javascripts
- To run specs in the browser run rake spec:javascripts:compile and then open the file RAILS_ROOT/spec/javascripts/compiled/suite.html in your browser of choice
- You can also run one spec at a time with either method by providing TEST=foo_spec.js (The compiled filename will change to foo_spec.html)
CHANGELOG
2008/08/22 - mdotterer
- Added a monkey patch to JSSpec to make to JSSpec.util.isDomNode work for DOMNodes created by env.js (Fixes include bug with prototype elements)
2008/08/21 - mdotterer
- Added an html fixturing method that can be used in both command line and compiled specs
- Changed rake task names to match rspec rake task names
- Fixed issue where innerHTML was broken when prototype was included
2008/08/20 - mdotterer
- Added simple spec compiler to create html files that can be run in the browser.
2008/08/19 - mdotterer
- Updated JSSpec to 2008/01/07 Version
- Created console_logger.js to display results of new version to console
- Added color
- Created runner.js to run any number of spec files with one set of results
and to pull out execution code to a common place
- Monkey patched JSSpec::Spec::extractOutSpecialEntries to ignore methods that
Prototype adds to Object
- Pulled generic library loads out of config.js so that config.js can be completely
customized for your project
- Added Rhino into the repository for convience
- Changed the rake task to run all of the files in
spec/javascripts/*_spec.js at once using runner.js
TODO
- Make color optional
- Make the runner and the compiler accept wildcards in their arguments
KNOWN ISSUES
- Expected and actual values don't appear in the report when a spec fails
- Location of errors doesn't work. (Currently thet are not displayed because of this)