Brief Description
Resetting a test server to a known state causes my tests to fail due to Ajax requests launched by DataTables instances being ongoing at the time the server is reset. I'd like to prevent this by stopping the DataTables requests before the server is reset.
Detailed Description
I have an application in which I use DataTables on some pages. These DataTables all perform server-side queries to populate their tables.
When I perform system testing, sometimes there is a race condition that can happen:
The test runner starts the test server.
The test runner loads in a test browser a page with a DataTable instance somewhere on it.
The test runner runs the test, which performs its checks and ends.
The test runner resets the test server to a known state for the next test.
An alert shows up on the page, saying that DataTables experienced an Ajax error. The alert says:
DataTables warning: table id=[some id] - Ajax error. For more information about this error, please see http://datatables.net/tn/7
- My testing system, which is not expecting the alert, is confused and registers a failure even though the test was in fact successful. (Or in some cases, it crashes.)
I know this happens because the server abruptly interrupted an Ajax request. What I am looking for is a way to prevent the alert from coming up in the first place. I'd like to stop all ongoing DataTables requests before the server is reset.
Solutions already rejected
Tell the DataTables instances not to use alerts: I want my tests to fail louldly if a DataTables instance runs into an issue that is not related to resetting the test server.
Modifying the test server: I prefer to keep the server simple and not worry there about requests that may go unanswered.
Wait client-side for all requests to be over: this can slow down tests considerably, especially when this wait is repeated for dozens of tests.
Direct the test browser to a new page, without DataTables on it, as this will interrupt the current requests: again this will hurt test performance.