Unit testing Ajax requests with Mocha

added by JavaScript Kicks
4/6/2015 10:20:59 AM

2 Kicks, 193 Views

Ajax requests can easily go wrong. You can't guarantee the connection and the server always work correctly. They are also often used to send user input to the server and back, so it's vital the data is handled correctly. But testing them can be tricky. It's asynchronous, and a good unit test must be isolated, so how can we do that when the code talks to the server?