mardi 31 mars 2015

Simulate connection errors

We've been using protractor for end-to-end testing for a while.


Now we are trying to cover several corner cases, which involves modifying the response from the API endpoint requests - for this we are using protractor-http-mock which provides an easy-to-use way to replace HTTP responses with pre-defined mocks.


But, what if we want to test a situation when a sudden connection loss happens? What are our options in this case?


In other words, we want to achieve a case when requests to specific endpoints would produce a network connection error and see how our application would react.




I'm open to any suggestions, I am currently thinking of the following strategies:



  • see if there are third-party nodejs libraries similar to protractor-http-mock

  • fire up a proxy and somehow control it during the tests (grunt-connect-proxy looks pretty mature though I'm not sure if it is possible to dynamically change the behavior of the proxy from spec to spec)

  • control it on a browser level - e.g. with a Network Throttling google chrome feature (though I'm pretty sure it is something that selenium cannot control, Network throttling with chrome and selenium)


Aucun commentaire:

Enregistrer un commentaire