How to test ajax error callback? How to test ajax error callback? selenium selenium

How to test ajax error callback?


You could simply put an incorrect URL into the URL attribute of the AJAX call.


What I do is just turn my server off before I make the AJAX request, which will simulate the server not responding.

Remember it'll need to be switched back on before you can refresh for changes.


You have to stub the ajax request, and return a custom response that will trigger the error callback. You can do this easily with Javascript testing frameworks such as Jasmine.