Passing a function as argument to addMockModule
I am having issues passing a function as an argument to addMockModule. If anyone has any idea of why this is happening, please reply to this StackOverflow question: http://stackoverflow.com/questions/33285982/passing-a-function-as-argument-to-addmockmodule
Okay so apparently the issue is that addMockModule is calling executeScript to deal with the arguments in order to bridge the Angular/Protractor context. exectuteScript is serializing this data to string. Any possibility that this is fixed or a workaround is found? Thanks.
Just as an update, for now I am deserializing it manually, like this:
var startBody = x.indexOf('{') + 1; var endBody = x.lastIndexOf('}'); var startArgs = x.indexOf('(') + 1; var endArgs = x.indexOf(')');
var myFun = new Function(x.substring(startArgs, endArgs), x.substring(startBody, endBody));
It works, at least on simple functions :)
You can pass additional arguments to the script, as noted in the varArgs section here: http://angular.github.io/protractor/#/api?view=Protractor.prototype.addMockModule
We should improve the documentation noting that this will be executed in the browser context.