atecarlos / protractor-http-mock

A library designed to work alongside Protractor for setting up mocks for your HTTP ajax requests.
MIT License
173 stars 70 forks source link

Add ability to set a responseDelay value. #81

Closed danieljin closed 8 years ago

danieljin commented 8 years ago

Obviously more documentation and testing is needed, but I was wondering whether there would be any want for adding this feature to the main repository.

This provided to be useful when I wanted mocked calls to hang in order to test our loading icon.

mock([{
    request: { },
    response: { },
    responseDelay: 1000 // milliseconds
}]);
atecarlos commented 8 years ago

Hi @danieljin . It's an interesting problem. I do see some value in it, but I also see a bit of potential problems with it given the inexact nature of the setTimeout and just UI testing itself.

How was your experience with it? Did you find it worked reliably enough that you were able to verify your loading state consistently?

danieljin commented 8 years ago

@atecarlos It's been working well for me. Our protractor tests that checks for the loading modal during the response delay and then checks that it's hidden afterwards is passing consistently.

atecarlos commented 8 years ago

Hi @danieljin . I made a minor schema change to your PR. Basically, instead of responsdeDelay, I added it to the response object. Therefore, now you define it as response.delay.

Here is the commit

This is now live in version 0.6.0

danieljin commented 8 years ago

This is awesome. Thanks @atecarlos