karma.conf.js
function setConfig(defaultConfig, server) {
    if (server === 'ne') {
        defaultConfig.captureTimeout = 100000;

        defaultConfig.customLaunchers = {
            'IE8': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '8'
            },
            'IE9': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '9'
            },
            'IE10': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '10'
            },
            'IE11': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '11'
            },
            'Edge': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'MicrosoftEdge'
            },
            'Chrome-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'chrome'
            },
            'Firefox-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'firefox'
            },
            'Safari-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'safari'
            }
        };

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        defaultConfig.browsers = [
            'IE8',
            'IE9',
            'IE10',
            'IE11',
            'Edge',
            'Chrome-WebDriver',
            'Firefox-WebDriver'
            // 'Safari-WebDriver' // active only when safari test is needed
        ];

        defaultConfig.webpack.module.preLoaders = [{
            test: /\.js$/,
            include: path.resolve('./src/js'),
            loader: 'istanbul-instrumenter'
        }];

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        defaultConfig.reporters = [
            'dots',
            'coverage',
            'junit'
        ];

        // optionally, configure the reporter
        defaultConfig.coverageReporter = {
            dir: 'report/coverage/',
            reporters: [
                {
                    type: 'html',
                    subdir: function(browser) {
                        return 'report-html/' + browser;
                    }
                },
                {
                    type: 'cobertura',
                    subdir: function(browser) {
                        return 'report-cobertura/' + browser;
                    },
                    file: 'cobertura.txt'
                }
            ]
        };

        defaultConfig.junitReporter = {
            outputDir: 'report/junit',
            suite: ''
        };
    } else {
        defaultConfig.captureTimeout = 60000;

        defaultConfig.reporters = [
            'karmaSimpleReporter'
        ];

        defaultConfig.specReporter = {
            suppressPassed: true,
            suppressSkipped: true,
            suppressErrorSummary: true
        };

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        defaultConfig.browsers = [
            'ChromeHeadless'
        ];
    }
}
function setConfig(defaultConfig, server) {
    if (server === 'ne') {
        defaultConfig.captureTimeout = 100000;

        defaultConfig.customLaunchers = {
            'IE8': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '8'
            },
            'IE9': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '9'
            },
            'IE10': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '10'
            },
            'IE11': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'internet explorer',
                version: '11'
            },
            'Edge': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'MicrosoftEdge'
            },
            'Chrome-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'chrome'
            },
            'Firefox-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'firefox'
            },
            'Safari-WebDriver': {
                base: 'WebDriver',
                config: webdriverConfig,
                browserName: 'safari'
            }
        };

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        defaultConfig.browsers = [
            'IE8',
            'IE9',
            'IE10',
            'IE11',
            'Edge',
            'Chrome-WebDriver',
            'Firefox-WebDriver'
            // 'Safari-WebDriver' // active only when safari test is needed
        ];

        defaultConfig.webpack.module.preLoaders = [{
            test: /\.js$/,
            include: path.resolve('./src/js'),
            loader: 'istanbul-instrumenter'
        }];

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        defaultConfig.reporters = [
            'dots',
            'coverage',
            'junit'
        ];

        // optionally, configure the reporter
        defaultConfig.coverageReporter = {
            dir: 'report/coverage/',
            reporters: [
                {
                    type: 'html',
                    subdir: function(browser) {
                        return 'report-html/' + browser;
                    }
                },
                {
                    type: 'cobertura',
                    subdir: function(browser) {
                        return 'report-cobertura/' + browser;
                    },
                    file: 'cobertura.txt'
                }
            ]
        };

        defaultConfig.junitReporter = {
            outputDir: 'report/junit',
            suite: ''
        };
    } else {
        defaultConfig.captureTimeout = 60000;

        defaultConfig.reporters = [
            'karmaSimpleReporter'
        ];

        defaultConfig.specReporter = {
            suppressPassed: true,
            suppressSkipped: true,
            suppressErrorSummary: true
        };

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        defaultConfig.browsers = [
            'ChromeHeadless'
        ];
    }
}
function setConfig ( defaultConfig , server ) { if ( server === 'ne' ) { defaultConfig . captureTimeout = 100000 ; defaultConfig . customLaunchers = { 'IE8' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'internet explorer' , version : '8' } , 'IE9' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'internet explorer' , version : '9' } , 'IE10' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'internet explorer' , version : '10' } , 'IE11' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'internet explorer' , version : '11' } , 'Edge' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'MicrosoftEdge' } , 'Chrome-WebDriver' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'chrome' } , 'Firefox-WebDriver' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'firefox' } , 'Safari-WebDriver' : { base : 'WebDriver' , config : webdriverConfig , browserName : 'safari' } } ; // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher defaultConfig . browsers = [ 'IE8' , 'IE9' , 'IE10' , 'IE11' , 'Edge' , 'Chrome-WebDriver' , 'Firefox-WebDriver' // 'Safari-WebDriver' // active only when safari test is needed ] ; defaultConfig . webpack . module . preLoaders = [ { test : / \.js$ / , include : path . resolve ( './src/js' ) , loader : 'istanbul-instrumenter' } ] ; // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter defaultConfig . reporters = [ 'dots' , 'coverage' , 'junit' ] ; // optionally, configure the reporter defaultConfig . coverageReporter = { dir : 'report/coverage/' , reporters : [ { type : 'html' , subdir : function ( browser ) { return 'report-html/' + browser ; } } , { type : 'cobertura' , subdir : function ( browser ) { return 'report-cobertura/' + browser ; } , file : 'cobertura.txt' } ] } ; defaultConfig . junitReporter = { outputDir : 'report/junit' , suite : '' } ; } else { defaultConfig . captureTimeout = 60000 ; defaultConfig . reporters = [ 'karmaSimpleReporter' ] ; defaultConfig . specReporter = { suppressPassed : true , suppressSkipped : true , suppressErrorSummary : true } ; // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher defaultConfig . browsers = [ 'ChromeHeadless' ] ; } }
Set config by environment
@param {object} defaultConfig - default config
@param {string} server - server type ('ne' or local)
Set config by environment