Skip to content

smparkes/jazz

Repository files navigation

jazz

Description

Support for running JS tests and specs under env.js and browsers. jazz cooperates with wake and envjs to track dependences for incremental build and test.

Install

You can install the gem via gem install smparkes-jazz. If you want to install from github (github.com/smparkes/jazz), you’ll need to checkout the Jasmine submodule (git submodule update --init) and also need to make sure you have the prerequisites listed in the gemspec in the Rakefile. rake gemspec will then build and copy the necessary parts of Jasmine.

If you want to run the examples/tests, you’ll need jQuery. The git submodule update --init command will have brought in jQuery, but you’ll need to build it: cd vendor/jquery && make.

Even if you install the gem, you may want to get the github files to see and run the examples.

Use

From the root of a project, i.e., the parent of the spec directory, you can use the jazz command as you would the rspec spec command, e.g.,

jazz spec/foo_spec.js spec/bar_spec.js

You can also execute HTML specs via jazz:

jazz spec/foo_spec.html

or even normal pages, that have the proper hooks to run as examples (see below).

HTML files must be valid XML, i.e., XHTML, at this time.

The HTML fixture must load the necessary test files. Any number of fixtures can be passed to the jazz command.

jazz uses env.js to run the tests, feeding it your HTML and JavaScript, plus the necessary JavaScript and controls to make the tests run correctly. You can see the entire envjsrb command by passing jazz the -v flag.

The Jasmine tests are configured to report results in streaming XML (JUnit format, more or less), which jazz turns into the familiar rspec format. The --xml flag causes jazz to display the raw XML output.

To run all the tests in the spec directory repeatedly you can use wake:

rake test

or

wake

See jazz’s Wakefile file and the discussion on examples below.

You can also try using autojaz as you would use autospec:

autojaz

You’ll need to install the ZenTest gem if you don’t have it installed; jazz can be used without ZenTest installed, but autojaz cannot be. Note that autojaz may be deprecated in favor of wake.

Screen shot at www.scrnshots.com/users/smparkes/screenshots/206033

Examples

There are examples in examples/* and spec/examples/*. You can run the tests with rake test which will run wake against the Wakefile. (Wake as a runner will probably replace autojaz.) You’ll need the wake gem.

Running wake will run all the tests and then watch the file system for changes. When it sees a change, it reruns the test. It knows how to find the HTML fixtures for specs where they exist in the right place, or it just runs the JavaScript spec itself. An example of the former is the pair example/hello_world.html and spec/example/hello_world_spec.js: jazz will reload the HTML if either file is changed. An example of the latter is spec/example/plain_spec.js.

You can also load the individual HTML files in the browser to run the tests there. For example, on a Mac, open example/hello_world.html. (The idea is that for production, the spec helper files are changed to not load the tests: that should be the only change necessary. Or the <script> tag could be ripped out.) Note that to run the tests from the filesystem in Firefox, you’ll need to set the security.fileuri.strict_origin_policy option to true.

Recent Changes

  1. Pass dependence flag to envjsrb to support wake dependences

  2. Add wake support

  3. Add example

  4. Support multiple fixtures on the jazz command. (Actually, this is entirely due to envjsrb supporting multiple fixtures. You need a recent build from github or an smparkes-envjs gem version of at least 0.0.5.)

Things to do

  1. Complete and test support for loading against an HTTP server.

  2. Focus on failing tests until fixed, a la autotest.

  3. Extend to more frameworks, e.g., qunit. There’s little here that’s actually Jasmine-specific.

  4. Including a missing script should be an error

  5. Make work in interactive mode (requires intro/outro/out:blank intergration with envjsrb)

Copyright © 2009 Steven Parkes. See LICENSE for details.

About

Run javascript tests from various frameworks in various environments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published