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

Problem with mock and interceptors #13

Closed marcelijanowski closed 9 years ago

marcelijanowski commented 9 years ago

Hi All, I have problem with using this node library. I seems like every stuff I mocked not going though angular interceptor so results on frontend are different then expected because they are not transform before and after going though interceptor.

So in my angular app I have this interceptor:

return {
      request: function request (config) {
        config = _.assign(config, cfg.httpConfiguration);
        config.headers['Content-Type'] = 'application/json';
        return config;
      },
      response: function response (response) {
        return (response.config['verbose']) ? response.data.content : response;
      }
    };

But when I mocking http backend not picking up this and on frontend I have wrong response

atecarlos commented 9 years ago

Hi @marcelijanowski . This is a known issue with this plugin. I have not been able to mock that interaction correctly, but I will continue to look into it.

marcelijanowski commented 9 years ago

I started looking at this because I need it. Would like really to help. So if I can become contributor to this project I probably would fix it. Also would like to talk with you about unit testing .

atecarlos commented 9 years ago

Hi @marcelijanowski . What is your question about unit testing?

marcelijanowski commented 9 years ago

I don't understand how you testing this because for me saying var expectations = [{"one":"mock-one"},{"two":"mock-two"} is little poor for tests. I was assuming that you going to use angular and your will return something not like .toContrain ?

matthewjh commented 9 years ago

See https://github.com/atecarlos/protractor-http-mock/pull/31