QUnit: Detect unfinished jQuery effects or ajax requests in teardown
Based on jQuery test suite https://github.com/jquery/jquery/blob/bcca4f041/test/data/testrunner.js#L113-L125 Change-Id: I1dba146a6795887c23c806f292c6425662ea4aad
This commit is contained in:
parent
58c3d520dc
commit
b90c69cdf7
1 changed files with 12 additions and 0 deletions
|
|
@ -240,6 +240,18 @@
|
|||
// As a convenience feature, automatically restore warnings if they're
|
||||
// still suppressed by the end of the test.
|
||||
restoreWarnings();
|
||||
|
||||
// Check for (and clean up, if possible) incomplete animations/requests/etc.
|
||||
if ( $.timers && $.timers.length !== 0 ) {
|
||||
// Test may need to use fake timers, wait for animations or
|
||||
// call $.fx.stop().
|
||||
throw new Error( 'Unfinished animations: ' + $.timers.length );
|
||||
}
|
||||
if ( $.active !== undefined && $.active !== 0 ) {
|
||||
// Test may need to use fake XHR, wait for requests or
|
||||
// call abort().
|
||||
throw new Error( 'Unfinished AJAX requests: ' + $.active );
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue