Test case containing various tests to run.
_waitTimeout
Calls YUITest.Assert.fail()
with a message indicating wait()
was called,
but resume()
was never called.
assert
condition
message
Asserts that a given condition is true. If not, then a YUITest.AssertionError object is thrown and the test fails.
callback
Method to call from an async init method to restart the test case. When called, returns a function that should be called when tests are ready to continue.
The function to call as a callback.
destroy
Function to run once after tests finish running. This executes after the last call to tearDown().
fail
message
Forces an assertion error to occur. Shortcut for YUITest.Assert.fail().
message
String
(Optional) The message to display with the failure.
init
Function to run once before tests start to run. This executes before the first call to setUp().
next
callback
[context]
Creates a callback that automatically resumes the test. Parameters as passed on to the callback.
wrapped callback that resumes the test.
// using test.resume()
Y.jsonp(uri, function (response) {
test.resume(function () {
Y.Assert.isObject(response);
});
});
test.wait();
// using test.next()
Y.jsonp(uri, test.next(function (response) {
Y.Assert.isObject(response);
}));
test.wait();
resume
segment
Resumes a paused test and runs the given function.
segment
Function
(Optional) The function to run. If omitted, the test automatically passes.
setUp
Function to run before each test is executed.
tearDown
Function to run after each test is executed.
wait
segment
delay
Causes the test case to wait a specified amount of time and then continue executing the given code.
waitFor
condition
segment
[timeout=10000]
[increment=100]
Delays the current test until condition returns a truthy value. If condition fails to return a truthy value before timeout milliseconds have passed, the test fails. Default timeout is 10s.
condition will be executed every increment milliseconds (default 100).
condition
Function
Function executed to indicate whether to execute segment
segment
Function
Function to check the success or failure of this test
[timeout=10000]
Number
optional
Maximum number of milliseconds to wait for condition to return true
[increment=100]
Number
optional
Milliseconds to wait before checking condition
DEFAULT_WAIT
Default delay for a test failure when wait()
is called without a delay.
Default: 10000