karma-runner / karma-runner/karma-coverage

Adding "coverage" to reporters array causes lock-up

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

Description

My configuration is as follows (`karma.conf.js`):

```javascript
const [webpackConfig] = require("./webpack.config.js");
webpackConfig.entry = function(){return {}};

const { BROWSER = "chrome" } = process.env;
const browsers = [];
if (BROWSER === "chrome") {
browsers.push("ChromeNoSecurity");
} else if (BROWSER === "firefox") {
browsers.push("FirefoxHeadless");
}

module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["mocha", "chai-as-promised", "chai", "sinon"],

// list of files / patterns to load in the browser
files: [
"source/**/*.js",
"test/index.js"
],

// list of files / patterns to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"source/**/*.js": ["webpack", "coverage"],
"test/index.js": ["webpack"],
"test/**/*.spec.js": ["webpack"]
},

webpack: webpackConfig,

webpackMiddleware: {
noInfo: false
},

// test results reporter to use
// possible values: "dots", "progress"
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["spec"],

coverageReporter: {
type: "text-summary",
check: {
global: {
statements: 55,
branches: 19,
functions: 60,
lines: 60
}
},
watermarks: {
statements: [ 50, 85 ],
functions: [ 50, 85 ],
branches: [ 50, 85 ],
lines: [ 50, 85 ]
},
instrumenterOptions: {
istanbul: { noCompact: true }
}
},

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

customLaunchers: {
ChromeNoSecurity: {
base: "Chrome",
flags: ["--disable-web-security", "--headless", "--remote-debugging-port=9222"]
},
FirefoxHeadless: {
base: "Firefox",
flags: ["-headless"]
}
},

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers,

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
}
```

And this works fine, albeit without coverage. Changing `reporters: ["spec"]` to `reporters: ["spec", "coverage"]` causes karma to go in to running forever and I have to kill the process after some minutes of strong CPU and memory usage.

Contributor guide

Open the contributing guide

Research direction

Start with the reported karma.conf.js configuration and its webpack.config.js dependency, then reproduce the run with reporters set to ["spec", "coverage"]. Inspect the interaction between the coverageReporter settings and the coverage reporter; done means coverage runs without the lock-up, excessive CPU or memory use, and the Karma process completes normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.