From jQuery JavaScript Library
« Back to QUnit
expect( amount )
Specify how many assertions are expected to run within a test.
Most useful when testing async code, where a failure usually prevents assertions to run at all.
Arguments:| amount | Integer | |
|---|
| The number of assertions you expect to run. |
Examples:| Name | Type |
The getJSON call may fail, so the equals-assertion is never run. To make sure the test fails, expect is called to specify that there should be at least one assertion.
test("a test", function() {
expect(1);
stop();
$.getJSON("/someurl", function(result) {
equals(result.value, "someExpectedValue");
start();
});
});