Karma will not start (socket.io throw error)

I have an Angular 2 project written in Typescript. I am trying to configure Travis CI. Unfortunately, I get an error message from Karma:

Missing error handler on socket .

TypeError: (msg || "") .replace is not a function

Expected Behavior

My Travis CI build to complete the Jasmine Unit tests, reporting the launch of the room and success and failure.

Actual behavior

This is the result from my build log. Here is a complete build log. Also here is the complete github repository that was being built.

 [09:39:04] Starting 'client.unit_test'... 05 04 2016 09:39:04.281:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/ 05 04 2016 09:39:04.287:INFO [launcher]: Starting browser Chrome 05 04 2016 09:39:05.519:INFO [Chrome 49.0.2623 (Linux 0.0.0)]: Connected on socket /#7wcOJ3uFvZX-HgZeAAAA with id 49035067 Missing error handler on `socket`. TypeError: (msg || "").replace is not a function at /home/travis/build/georgeedwards/Gen-App/node_modules/karma/lib/reporter.js:45:23 at [object Object].onBrowserError (/home/travis/build/georgeedwards/Gen-App/node_modules/karma/lib/reporters/base.js:58:60) 

Environmental Details

Node v5.10.0

Angular 2.0.0-beta.12

 ├── karma@0.13.22 ├── karma-chrome-launcher@0.1.12 ├── karma-coverage@0.2.7 ├── karma-firefox-launcher@0.1.7 ├── karma-ie-launcher@0.1.5 ├── karma-jasmine@0.3.8 ├── karma-ng-html2js-preprocessor@0.1.2 ├── karma-opera-launcher@0.1.0 ├── karma-phantomjs-launcher@0.1.4 

Any ideas what might be causing this, or what information you might need to debug this?

+5
source share
1 answer

I have seen problems like this in the past. In 99% of cases, this is due to the fact that the file in the karma.conf.js array karma.conf.js not a file that refers to the application.

Another probable problem is that the module names are incorrectly translated from their respective file names.

Here is a snippet of my karma-test-shim.js where I rewrite the file names into module names:

 System.config({ packages: { 'base/wwwroot/app': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). filter(function onlyAppFiles(filePath) { return /^\/base\/wwwroot\/app\/.*\.js$/.test(filePath) }). reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma fingerprint in path, eg: var moduleName = appPath.replace(/^\/base\/wwwroot\/app\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; return pathsMapping; }, {}) } } }); 

The structure of my project:

 / karma.conf.js karma-test-shim.js wwwroot/ app/ //Angular 2 project and spec files 

Julia Ralph, the developer of the Angular 2 team, has an initial project for setting up karma tests for the Angular 2 project, which I thought was very useful in creating a karma pad.

+2
source

Source: https://habr.com/ru/post/1246463/


All Articles