Angularjs ';未定义';不是一个函数(评估和包含)业力测试

Angularjs ';未定义';不是一个函数(评估和包含)业力测试,angularjs,npm,phantomjs,underscore.js,lodash,Angularjs,Npm,Phantomjs,Underscore.js,Lodash,在运行karma测试时,我在jenkins构建中遇到了这个错误。因此,为了清楚起见,这在本地运行良好,并且我的所有测试都通过了,但是当我在jenkins box上运行完全相同的代码时,我得到了错误: PhantomJS 1.9.8 (Linux 0.0.0) VisitDataSpec #emailExists should return true if email is already FAILED TypeError: 'undefined' is not a function (e

在运行karma测试时,我在jenkins构建中遇到了这个错误。因此,为了清楚起见,这在本地运行良好,并且我的所有测试都通过了,但是当我在jenkins box上运行完全相同的代码时,我得到了错误:

PhantomJS 1.9.8 (Linux 0.0.0) VisitDataSpec #emailExists should return true if email is already FAILED
    TypeError: 'undefined' is not a function (evaluating '_.contains(visitEmails,email)')
        at /home/server/jenkins/workspace/Reception UI Build/src/app/model/VisitData.js:9
        at /home/server/jenkins/workspace/Reception UI Build/test/app/model/VisitData.spec.js:208
我闻到了幽灵战车的味道。服务器上的版本为1.9.0。我将我的本地版本降级为相同的版本,试图在本地重现问题,但没有发生

我已经尝试过同时包含下划线和lodash,但这些库都不起作用

在restanglar尝试使用下划线的测试中,我遇到了相同的错误:

PhantomJS 1.9.8 (Linux 0.0.0) EmailVisitControllerSpec #signIn should call VisitService to add a new service with scope data FAILED
    TypeError: 'undefined' is not a function (evaluating '_.contains(safeMethods, operation.toLowerCase())')
        at /home/server/jenkins/workspace/Reception UI Build/bower_components/restangular/dist/restangular.js:21
        at elemFunction (/home/server/jenkins/workspace/Reception UI Build/bower_components/restangular/dist/restangular.js:1217)
        at wrapper (/home/server/jenkins/workspace/Reception UI Build/bower_components/lodash/lodash.js:3949)
        at postFunction (/home/server/jenkins/workspace/Reception UI Build/bower_components/restangular/dist/restangular.js:1246)
        at apply (/home/server/jenkins/workspace/Reception UI Build/bower_components/lodash/lodash.js:402)
        at wrapper (/home/server/jenkins/workspace/Reception UI Build/bower_components/lodash/lodash.js:4254)
        at /home/server/jenkins/workspace/Reception UI Build/src/app/rest/VisitService.js:9
        at invoke (/home/server/jenkins/workspace/Reception UI Build/node_modules/karma-sinon-chai/node_modules/sinon/pkg/sinon.js:2583)
        at addVisit (:1)
        at /home/server/jenkins/workspace/Reception UI Build/src/app/visits/EmailVisitController.js:9
        at /home/server/jenkins/workspace/Reception UI Build/test/app/visits/EmailVisitController.spec.js:91
使用angular 1.4.2、angular mocks 1.4.2、mocha 2.3.4和现在的下划线1.8.3或lodash 3.10.1(尝试使用其中一种)

顺便说一句,这可能是相关的:在詹金斯的基础上,我有四个:

npm WARN install Couldn't install optional dependency: Unsupported
也许它没有解决一些依赖关系,但不幸的是,我看不出是哪些依赖关系。使用npm 3.3.2


有人对我在这里遗漏的东西有什么想法吗?任何已知的不兼容版本?

我发现了问题:lodash 4.x。移回3.10.1,一切正常。

是的,restangular内有一行:

 "dependencies": {
    "lodash": ">=1.3.0"
  },
lodash最近刚刚升级到4.0版,所以现在当您安装restangular时,它将下载最新版本的lodash

要解决此问题,只需在版本3.10.1中添加lodash即可,您的依赖项(npm或bower):


我这里也有同样的问题-你找到解决方案了吗?我实际上已经在使用3.10.1了。我也尝试用下划线代替lodash,但也不起作用。我也在使用3.10.1,但我的CI将其更新为4.X。我刚刚在bower.json中添加了lodash#3.10.1。希望这会有帮助。它对我来说真的不起作用。无论如何,开发人员似乎不再支持Restanglar,所以我停止使用它。
  "dependencies": {
    ...
    "restangular": "1.5.1",
    ...
    "lodash": "3.10.1"
  }