README revision 160dc8e953e71d6ef7fedc3d518b63ffa62328ca
Tests are defined in an object hash mapping test names to test objects. A test
object may have the following properties, of which only the "test" property is
required:
asyncSetup (Boolean):
By default, setup functions are assumed to be synchronous. Set this to true
to indicate that your setup function is asynchronous. This will cause the
test runner to wait for you to explicitly indicate completion by calling
done() from within the setup function.
You may optionally pass a value to done(). To indicate a setup failure, pass
false, and the test will be aborted (just as it would if you returned false
from a synchronous setup function).
bootstrapYUI (Boolean):
By default, all sandboxes are pristine. Set this to true to automatically
bootstrap YUI3 core and Loader into the test sandbox.
duration (Number):
Time duration in milliseconds during which the number of successful runs
will be counted when using time-based testing. Defaults to 1000 if not
specified.
iterations (Number):
Number of iterations to run when using iteration-based testing. Defaults
to 1 if not specified.
preloadUrls (Object):
Object hash of keys mapped to publicly-accessible URLs. Each URL will be
preloaded via a cross-domain YQL proxy, and its contents will be made
available to the setup/teardown/test functions as sandbox.preload.key, where
"key" is the same key that was used on the preloadUrls object.
setup (Function):
Setup function to execute before each iteration of the test. Runs in the
same sandbox as the test. If the setup function returns false, the test will
be aborted.
teardown (Function):
Teardown function to execute after each iteration of the test. Runs in the
same sandbox as the test.
test (Function):
The test itself, each iteration of which will be timed. The test function
must call done() when it's completely finished; until this happens, the
next test cannot run and the profile timer will keep ticking.
If you pass false to done(), the test will be considered a failure.
Otherwise it will be considered a success.
useStrictSandbox (Boolean):
By default, each test gets a single sandbox which is reused for all
iterations of that test. Set this to true if you want a brand new sandbox
to be created for each iteration of the test.
warmup (Boolean):
If this is true, the test will be run once (and timing data discarded) as a
warmup before the main iterations begin.
Your test code in the setup, test, and teardown functions also has access to a
special "sandbox" object, on which your test may get and set properties to share
information with the test runner.
The sandbox object contains the following utility methods:
log()
arguments and functionality apply.
xhrGet(url)
Performs a synchronous XMLHttpRequest on the specified URL and returns the
responseText. If the XHR call fails (for example, due to a same-origin
restriction or because the test is being run from the local filesystem),
null will be returned and a warning will be logged in the parent window.