Karma error when running angular2 tests via jenkins on linux

风流意气都作罢 提交于 2019-12-19 02:32:47

问题


I am seeing the following error when running my angular2 unit tests using karma with jenkins.

My tests run fine when I run them on my local machine (windows), however when running the test via jenkins on linux I get the following error.

Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at /home/hudson/.hudson/jobs/workspace/pjt/node_modules/karma/lib/reporter.js:45:23

My tests are never started any ideas what could be causing this. I took a look at the karma source code and I couldn't figure out why there would be a problem.

  return function (msg, indentation) {
// remove domain and timestamp from source files
// and resolve base path / absolute path urls into absolute path
msg = (msg || '').replace(URL_REGEXP, function (_, prefix, path, __, ___, line, ____, column) {
  if (prefix === 'base') {
    path = basePath + path
  }
  // more code here ...

I'm using PhantomJS as the test runner just in case that's relevant both locally and on jenkins.

I'd appreciate any pointers as to what may be the issue.


回答1:


To answer my own question on this.

Turns out the problem was with my karma files section.

  { pattern: 'node_modules/rxjs/bundles/rx.js', included: true, watched: true }

The filename for the rx module is node_modules/rxjs/bundles/Rx.js

With linux being case sensitive this is the reason it worked on a windows dev environment and failed on the linux build server.

The 404 message for the rx.js file was present in the logs but I missed among a lot of other debug logging.

Lesson learned :)




回答2:


for anyone following https://github.com/juliemr/ng2-test-seed, in my case this error occurred due to this line of code : https://github.com/juliemr/ng2-test-seed/blob/master/karma-test-shim.js#L31.

Updating it to

System.import('angular2/src/platform/browser/browser_adapter')

will rectify the problem. Hope it helps someone.



来源:https://stackoverflow.com/questions/35817590/karma-error-when-running-angular2-tests-via-jenkins-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!