在运行我的业力测试时,我在jenkins构建中遇到此错误。所以要说清楚,这在本地工作正常,我的所有测试都通过,但是当我在jenkins框上运行完全相同的代码时,我得到错误:
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,但没有一个库可以工作。
我在Restangular尝试使用下划线的测试中得到了同样的错误:
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
使用角度1.4.2,角度模拟1.4.2,摩卡2.3.4和现在,下划线1.8.3或lodash 3.10.1(尝试使用其中任何一种)。
顺便说一句,这可能是相关的:我在Jenkins上建立时有四个:
npm WARN install Couldn't install optional dependency: Unsupported
也许它没有解决一些依赖关系,但不幸的是我无法看到哪些依赖关系。使用npm 3.3.2。
有没有人对我在这里缺少的东西有任何想法?任何已知的不兼容版本?
答案 0 :(得分:2)
我发现了问题:lodash 4.x.回到3.10.1,一切正常。
答案 1 :(得分:0)
所以是的,restangular里面有这条线:
"dependencies": {
"lodash": ">=1.3.0"
},
lodash刚刚升级到4.0版,所以现在安装restangular时会下载最新版本的lodash
解决这个问题只需在版本3.10.1中添加lodash你的依赖项(npm或bower):
"dependencies": {
...
"restangular": "1.5.1",
...
"lodash": "3.10.1"
}