Exception when using "karma run"
segrey opened this issue · comments
- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
Executing "karma run" command fails.
- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
package.json
{
"devDependencies": {
"karma": "^4.0.1",
"karma-parallel": "^0.3.1",
"karma-jasmine": "^2.0.1",
"karma-junit-reporter": "^1.2.0",
"karma-chrome-launcher": "^2.2.0"
}
}
karma.conf.js
// karma.conf.js
module.exports = function(config) {
config.set({
// NOTE: 'parallel' must be the first framework in the list
frameworks: ['parallel', 'jasmine'],
reporters: ['junit'],
browsers: ['ChromeHeadless'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-junit-reporter'),
require('karma-parallel')
]
});
};
The issue can be reproduced even without tests.
- Run karma server in a terminal:
./node_modules/karma/bin/karma start
- In another terminal:
./node_modules/karma/bin/karma run
The error in the first terminal:
./node_modules/karma/bin/karma start
13 03 2019 00:55:27.477:INFO [framework:karma-parallel]: sharding specs across 11 browsers
13 03 2019 00:55:27.499:WARN [karma]: No captured browser, open http://localhost:9876/
13 03 2019 00:55:27.520:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
13 03 2019 00:55:27.520:INFO [launcher]: Launching browsers ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless, ChromeHeadless with concurrency unlimited
13 03 2019 00:55:27.525:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.531:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.534:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.538:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.542:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.547:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.553:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.558:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.563:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.570:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.580:INFO [launcher]: Starting browser ChromeHeadless
13 03 2019 00:55:27.890:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket gVlUptGuJOGShkK_AAAA with id 90761783
13 03 2019 00:55:27.898:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket N_FtZRy2OqgHMkE6AAAB with id 80372819
13 03 2019 00:55:27.903:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket UyvfpYyq21lsh05MAAAC with id 18730315
13 03 2019 00:55:27.918:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket Y0g0sZMctnz8hQ1hAAAE with id 24106570
13 03 2019 00:55:27.920:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket 3L6r8YfeA8DqM8frAAAD with id 9795099
13 03 2019 00:55:27.922:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket CTwbSKeI6-wwrOnFAAAF with id 45471051
13 03 2019 00:55:27.926:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket pS8so0QMW4ywdGzeAAAG with id 71035962
13 03 2019 00:55:27.928:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket Al6UUyL_2InW-92tAAAH with id 89172988
13 03 2019 00:55:27.931:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket 8AMWRMp6WX2CjOpKAAAI with id 60192581
13 03 2019 00:55:27.938:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket ECeJ-c-z8S6vTowXAAAJ with id 23653732
13 03 2019 00:55:27.945:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket HO08Wk7kNLs6mf9BAAAK with id 17973266
13 03 2019 00:55:32.808:ERROR [karma-server]: TypeError: Cannot read property 'push' of undefined
at _reporters.forEach (/home/user/my-project/node_modules/karma/lib/reporters/multi.js:11:61)
at Array.forEach (<anonymous>)
at MultiReporter.addAdapter (/home/user/my-project/node_modules/karma/lib/reporters/multi.js:11:21)
at Server.<anonymous> (/home/user/my-project/node_modules/karma/lib/middleware/runner.js:41:18)
at Object.onceWrapper (events.js:273:13)
at Server.emit (events.js:187:15)
at Executor.schedule (/home/user/my-project/node_modules/karma/lib/executor.js:30:20)
at Server.on (/home/user/my-project/node_modules/karma/lib/server.js:330:18)
at Server.emit (events.js:187:15)
at emit (/home/user/my-project/node_modules/karma/lib/file-list.js:29:21)
at FileList._emitModified (/home/user/my-project/node_modules/karma/lib/file-list.js:34:19)
at Promise.map.then (/home/user/my-project/node_modules/karma/lib/file-list.js:108:14)
at tryCatcher (/home/user/my-project/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/user/my-project/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/user/my-project/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/user/my-project/node_modules/bluebird/js/release/promise.js:614:10)
- What is the expected behavior?
It works without exceptions.
Please let me know if you need more information.
Adding this.adapters = [];
to AggregatedCoverageReporter
constructor fixes the issue.
Interesting. I have not used karma v4 yet, so I assume that is a factor here. Would you mind making a PR?
@joeljeske Done: #37
BTW, it's not specific to karma v4, reproduced with karma@1.7.1 too.
Oh interesting. I don’t think I understood the issue. You are running the server, and then attaching an additional karma instance to the server using karma run. I don’t think I have ever used this flow.
What is the use case for this type of flow?
I think I too quickly saw the karma v4 and assumed it was a compatibility issue.
Such a workflow allows to run a selected test only, e.g. karma run -- --grep="my suite"
. For example, tools like IDEs use it to run/re-run tests.
That pull request fixes this issue for me. Is it possible to get it merged in?