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

Mock dynamic url's #57

Closed alexandrmatsyuk92 closed 8 years ago

alexandrmatsyuk92 commented 8 years ago

Hi. I'm developing weather forecast app. Front-end of my app makes different get queries to server like this: localhost:3000/api/weather/22.30935/113.921988888889/1447970462561 localhost:3000/api/weather/49.13234/22.679924588889/1447938462456

Is there any way to mock this dynamic routes by your module?

For example: can I use something like this:

mock([{ request: { path: 'localhost:3000/api/weather///*', method: 'GET' }, response: { status: 200, data: {} } }]); ???

Thanks.

atecarlos commented 8 years ago

@alexandrmatsyuk92 are you expecting to mock different responses for each dynamic route?

You could define an expectation with simply "api/weather", but I doubt that will be sufficient for you. Perhaps a better approach could be to be able to define a function that returns the response data as opposed to a static JSON definition. That's not currently an option at the moment.