We have been utilizing the protractor
tool for end-to-end testing for quite some time.
Currently, we are exploring various corner cases that involve modifying the responses from API endpoint requests. To achieve this, we are utilizing protractor-http-mock
, which offers a convenient method to replace HTTP responses with predefined mocks.
However, what if we need to test a scenario where a sudden loss of connection occurs? What options do we have in such a situation?
In essence, we aim to create a situation where requests to specific endpoints result in a network connection error, allowing us to observe how our application responds.
I am open to suggestions, and I am currently considering the following strategies:
- Exploring third-party Node.js libraries similar to
protractor-http-mock
- Mocking the
$http
AngularJS service - Utilizing a proxy and finding a way to control it during tests (considering
grunt-connect-proxy
, which seems mature, but unsure about dynamically changing its behavior per test) - Managing it at a browser level - for example, using the Network Throttling feature in Google Chrome (though, it seems Selenium may not have control over this, see Network throttling with Chrome and Selenium) (considering a browser add-on/extension)