将函数作为参数传递给addMockModule

时间:2015-10-22 16:29:41

标签: javascript angularjs protractor ngmock

我有这个奇怪的问题,我将一个函数传递给addMockModule参数,它以字符串的形式返回:

functionName: "functionlogic"

变量等静态引用可以正常工作。这是代码:

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);

0 个答案:

没有答案