1

I have this weird issue where i'm passing a function to the addMockModule argument and it is being returned as a string in the form of:

functionName: "functionlogic"

Static references such as variables work fine. This is the code:

var x = function sayHello() {console.info('Say hello!')}

browser.addMockModule('moduleName', function(x) {

   function runBlock(){$httpBackend) {
      console.info(x);    // returns x function as a string
      x();                //returns unknown error: x is not a function
   }

   angular.module('moduleName', ['ngMockE2E', 'myApp'])
   .run(runBlock);
   runBlock.$inject = ['$httpBackend'];
}, x);
magicode118
  • 1,444
  • 2
  • 17
  • 26
  • 2
    Arguments for browser.addMockModule are serialized in the same way as for [`browser.executeScript()`](http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.executeScript) - *Functions will resolve to their string representation*. Try to move function logic inside addMockModule and only pass variables. – Michael Radionov Oct 23 '15 at 07:51

0 Answers0