nchaulet / httpbackend

Http backend mock module for protractor
MIT License
28 stars 10 forks source link

returning object while using function callback as respond #13

Closed GustavSt closed 9 years ago

GustavSt commented 9 years ago

Hello,

Is there a way to accomplish something like this:

function setupGet(returnValue){
  httpBackend.whenGET(/someRegex/).respond(function(method, url, data, headers, params){
    //edit returnValue in the callback
    returnValue.url = url; //Error returnValue is undefined
    return [200, returnValue];
  });
}

It works fine when providing just the returnValue in the respond function, but doing the above doesn't work. I assume since the callback seems to be executed in the browser while returnValue is in protractor, so when the function is executed, returnValue is not defined. Is there a way to accomplish this?

nchaulet commented 9 years ago

object must be declared in the callback because callback is injected in the browser you cannot access to global declared variable in node.

GustavSt commented 9 years ago

Ok