Open cgolubi1 opened 10 years ago
On #1104, we suggested using mocks to reduce some of the cases in which ajaxSetup is needed. In particular, where we need to manually call two functions in series during a test (e.g. when setting up a page and testing that form submission from that page works correctly), we should split such tests into two tests, one which mocks the form submission and tests that it is called correctly, and one which mocks or fakes the setup and tests the form submission function.
Since it might become inconvenient to get to my comments on the particular version of #1104 that I reviewed, I'll try to bring over some of the highlights of what I said there:
start()
statement inside their callbacks, so even if we're not actively trying to test that part of those methods, we should still be using mocks to prevent asynchronous calls and callbacks from executing in the background after we've moved on to other tests.Newgame.showNewgamePage()
, mock Newgame.getNewgameData()
instead of Newgame.showPage()
), so that we're just testing the specific unit that the unit test is for.
We believe it harms test isolation to use
ajaxSetup { async: false; }
as a mechanism for making parts of tests run synchronously. There are about 35 tests which still use this mechanism. Refactor those tests so they don't need to muck with ajaxSetup.