简体   繁体   English

在Linux上通过jenkins运行angular2测试时出现Karma错误

[英]Karma error when running angular2 tests via jenkins on linux

I am seeing the following error when running my angular2 unit tests using karma with jenkins. 当使用karma和jenkins运行我的angular2单元测试时,我看到以下错误。

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. 当我在本地机器(windows)上运行它时,我的测试运行正常,但是当在linux上通过jenkins运行测试时,我得到以下错误。

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. 我正在使用PhantomJS作为测试运行器,以防本地和jenkins相关。

I'd appreciate any pointers as to what may be the issue. 我很欣赏有关可能是什么问题的任何指示。

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 rx模块的文件名是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. 由于linux是区分大小写的,这就是它在Windows开发环境中工作并在linux构建服务器上失败的原因。

The 404 message for the rx.js file was present in the logs but I missed among a lot of other debug logging. rx.js文件的404消息存在于日志中,但我错过了许多其他调试日志记录。

Lesson learned :) 学过的知识 :)

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 . 对于跟随https://github.com/juliemr/ng2-test-seed的任何人,在我的情况下,由于以下代码行而发生此错误: 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. 希望它可以帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM