karma-runner / karma-runner/karma-coverage

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

Open
#233 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

Can someone explain to me what I am doing wrong with the karma coverage. I am currently developing an angular 2 (RC1) service in typescript and want to not only run unit tests on it but also provide code coverage reports. If running the tests without the coverage reporter all is good and the tests are run. Unfortunately, when I include the coverage reporter karma bails with the following error...

10 06 2016 10:45:49.583:DEBUG [web-server]: serving (cached): D:/Git/@my-namespace/my-service/node_modules/rxjs/scheduler/FutureAction.js
Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at D:\Git\@my-namespace\my-service\node_modules\karma\lib\reporter.js:45:23

What I am doing is building typescript into a folder called dist and then exposing this to karma test and coverage

details are below...

... any ideas...?
### Expected behavior

karma should run tests and create a coverage file
### Actual behavior

10 06 2016 10:45:49.583:DEBUG [web-server]: serving (cached): D:/Git/@my-namespace/my-service/node_modules/rxjs/scheduler/FutureAction.js
Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at D:\Git\@my-namespace\my-service\node_modules\karma\lib\reporter.js:45:23
### Enviroment Details

Typescript: 1.8.10
Karma version: 0.13.22
Karma coverage: 0.5.5

_karma.config.js_

``` javascript
module.exports = function(config) {

// transpiled app JS files
var appBase = "dist/";

// component assets fetched by Angular's compiler
var appAssets ="/base/dist/";

config.set({
autoWatch: true,
basePath: ".",
browserNoActivityTimeout: 20000,
browsers: ["Chrome"],
colors: true,
exclude: [
"node_modules/**/*.spec.js"
],
files: [
// Standard libs
"node_modules/systemjs/dist/system-polyfills.js",
"node_modules/systemjs/dist/system.src.js",
"node_modules/es6-shim/es6-shim.js",
"node_modules/reflect-metadata/Reflect.js",
"node_modules/zone.js/dist/zone.js",
"node_modules/zone.js/dist/jasmine-patch.js",
"node_modules/zone.js/dist/async-test.js",
"node_modules/zone.js/dist/fake-async-test.js",

// Standard libs with custom patterns
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},,
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},

// Custom shim
"karma-test-shim.js",

// Transpiled application & spec code paths loaded via module imports
{pattern: 'dist/**/*.js', included: false, watched: true},
{pattern: 'dist/**/*.js.map', included: false, watched: false}
],
frameworks: ["jasmine"],
logLevel: config.LOG_DEBUG,
plugins: [
"karma-jasmine",
"karma-chrome-launcher",
"karma-coverage"
],
port: 9876,
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
"dist/**/!(*spec).js": ["coverage"]
},
proxies: {
// proxied base paths for loading assets
// required for component assets fetched by Angular's compiler
"/dist/": appAssets
},
reporters: ["progress", "dots", "coverage"],
singleRun: true,
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.