joeljeske / karma-parallel

A Karma JS Framework to support sharding tests to run in parallel across multiple browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If it is used karma-junit-reporter then xml report contain tests from one browser instance only

KhalipskiSiarhei opened this issue · comments

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • **I'm submitting a ... **

    • bug report
    • feature request
    • support request => Please do not submit support request here, see note at the top of this template.
  • Do you want to request a feature or report a bug?
    I would like to request new feature

  • What is the current behavior?
    If it is used karma-junit-reporter then in xml report there are tests results from one browser instance only. The tests which are run in other browser instances are not considered in the available xml report. It looks like the same issue will be with other reports as well.

  • What is the expected behavior?
    It would be nice to combine all tests into one xml report or provide one xml report per browser instance. At this case we will have possibility to import these results for all browser instances.

  • What is the motivation / use case for changing the behavior?
    We are using karma-parallel package in CI build server and we need to get actual tests results embedded into CI build. For now we have only tests from one browser instance, but it is required to have all run tests embedded into CI buil.

  • Please tell us about your environment:

    "dependencies": {
        "@angular/animations": "5.2.3",
        "@angular/common": "5.2.3",
        "@angular/compiler": "5.2.3",
        "@angular/core": "5.2.3",
        "@angular/forms": "5.2.3",
        "@angular/http": "5.2.3",
        "@angular/platform-browser": "5.2.3",
        "@angular/platform-browser-dynamic": "5.2.3",
        "@angular/platform-server": "5.2.3",
        "@angular/router": "5.2.3",
        "@nguniversal/aspnetcore-engine": "5.0.0-beta.5",
        "@nguniversal/common": "5.0.0-beta.5",
        "@ngx-translate/core": "9.1.1",
        "core-js": "2.5.3",
        "moment": "2.18.1",
        "moment-timezone": "0.5.13",
        "preboot": "6.0.0-beta.1",
        "rxjs": "5.5.6",
        "zone.js": "0.8.20"
    "devDependencies": {
        "@angular/cli": "1.6.7",
        "@angular/compiler-cli": "5.2.3",
        "@angular/language-service": "5.2.3",
        "@angularclass/hmr": "~2.1.3",
        "@types/jasmine": "~2.8.3",
        "@types/jasminewd2": "~2.0.2",
        "@types/node": "~9.4.1",
        "codelyzer": "~4.1.0",
        "copy-webpack-plugin": "~4.3.1",
        "jasmine-core": "~2.8.0",
        "jasmine-reporters": "~2.3.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~2.0.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "~1.4.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "~0.2.2",
        "karma-junit-reporter": "~1.2.0",
        "karma-parallel": "~0.2.1",
        "protractor": "~5.3.0",
        "protractor-jasmine2-screenshot-reporter": "~0.5.0",
        "rxjs-tslint-rules": "~3.8.0",
        "ts-node": "~4.1.0",
        "tslint": "~5.9.1",
        "tslint-consistent-codestyle": "~1.11.1",
        "tslint-jasmine-rules": "~1.3.0",
        "typescript": "~2.5.3"

karma config file is the following:

// Karma configuration file, see link for more information

module.exports = function (config) {
        basePath: '',
        frameworks: ['parallel', 'jasmine', '@angular/cli'],
        parallelOptions: {
            // Defaults to cpu-count - 1
            executors: 3,
            shardStrategy: 'round-robin'
            // shardStrategy: 'description-length'  
        plugins: [
        client: {
            // leave Jasmine Spec Runner output visible in browser
            clearContext: false
        coverageIstanbulReporter: {
            reports: ['html', 'lcovonly', 'cobertura'],
            fixWebpackSourcePaths: true,
             thresholds: {
                // thresholds for all files
                global: {
                    statements: 97,
                    lines: 97,
                    branches: 74,
                    functions: 95
        angularCli: {
            environment: 'dev'
        files: [
        reporters: ['progress', 'kjhtml'],
        port: 35000,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: false,
        browsers: ['ChromeHeadless'],
        singleRun: true,
        concurrency: Infinity,
        customLaunchers: {
            ChromeHeadless: {
                base: 'Chrome',
                flags: [
                    // Without a remote debugging port, Google Chrome exits immediately.
                    // '--max_old_space_size=4096'
                debug: false
        // How long does Karma wait for a browser to reconnect (in ms).
        // With a flaky connection, it is pretty common that the browser disconnects, but the actual test execution is still running without any problems.
        // Karma does not treat a disconnection as an immediate failure and will wait for browserDisconnectTimeout (ms).If the browser reconnects during that time, everything is fine.
        // Default: 2000
        browserDisconnectTimeout: 6000,
        // The number of disconnections tolerated.
        // The disconnectTolerance value represents the maximum number of tries a browser will attempt in the case of a disconnection.
        // Usually, any disconnection is considered a failure, but this option allows you to define a tolerance level when there is a flaky network link between the Karma server and the browsers.
        // Default: 0
        browserDisconnectTolerance: 3,
        // How long will Karma wait for a message from a browser before disconnecting from it (in ms).
        // If, during test execution, Karma does not receive any message from a browser within browserNoActivityTimeout(ms), it will disconnect from the browser.
        // Default: 10000
        browserNoActivityTimeout: 60000,
        // Timeout for capturing a browser (in ms).
        // The captureTimeout value represents the maximum boot-up time allowed for a browser to start and connect to Karma.
        // If any browser does not get captured within the timeout, Karma will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
        // Default: 60000
        captureTimeout: 120000,
        // Karma will report all the tests that are slower than given time limit (in ms).This is disabled by default (since the default value is 0).
        reportSlowerThan: 1000
        // More info about disconnected issue is here:

I run tests via the following command:
ng test --watch=false --reporters=progress+junit+coverage-istanbul --single-run=true --config=karma.headless.parallel.conf.js

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Great idea! We almost already had junit support using the same strategy taken by the code coverage aggregation support. Junit had a couple of extra expectations in its reporter that I had to take into account. I also made Junit an aggregated reporter by default, as most would likely want to aggregate the reports into a single junit file.

This is now fixed and available in 0.2.4, please let me know if you continue to have issues

@joeljeske thanks for the reactive feedback! I will check it as soon as new package version will be available via yarn. Unfortunately just published version is still not available via yarn (I had the same issue previously and it was resolved indirectly after some time; cache and packages have been cleaned/removed).