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

Difference responses for a given endpoint? #87

Closed dagumak closed 8 years ago

dagumak commented 8 years ago

For example, I have an application that polls for changes. Is it possible to give a set of responses for it to return in sequence?

Crevil commented 8 years ago

This is not possible. What is your objective with this? It sounds to me like your trying to test several things at once?

dagumak commented 8 years ago

@Crevil the objective its to test a polling service which would only stop polling when the status reaches success or failure. What suggestions do you have for testing a polling service?

Crevil commented 8 years ago

I would test the polling action in one test and see that it requests the same endpoint several times. Next up I would make sure it stopped polling on a specific response. This success scenario does not need to test the polling mechanism again, as you already tested this.

Otherwise you could hack something with the dynamics mock APIs, something along returning one mock. After some delay push in a new response. But this relies on the time aspect of execution, which I don't like.

Crevil commented 8 years ago

Further more, I expect you to be e2e testing your application. This is, to me, more of a unit test, no?

dagumak commented 8 years ago

@Crevil Fair point, and solid advice. Yes, I am also running an e2e test for it.

Thank you