Karma error when running angular2 tests via jenkins on linux

I see the following error when executing my angular2 unit tests using karma with jenkins.

My tests run fine when I run them on my local machine (windows), however when I run the test through 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 

In my tests, no ideas have ever started that could cause this. I looked at the source code of karma, and I could not understand why the problem arose.

  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 use PhantomJS as a test runner just in case, both in local and in jenkins.

I would appreciate it to be a problem.

+7
angular karma-runner karma-jasmine
source share
2 answers

To answer my own question on this.

Turns out the problem was in my karma file section.

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

File name for rx module: node_modules / rxjs / bundles / Rx.js

Given that linux is case sensitive, this caused it to run in a windows dev environment and fail on the Linux build server.

A 404 message for the rx.js file was present in the logs, but I missed many other debugging protocols.

Lesson learned :)

+3
source share

for those who follow 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 .

Upgrade to

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

fix the problem. Hope this helps someone.

+2
source share

All Articles