How to use the karma.config.parseConfig function in karma

To help you get started, we’ve selected a few karma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keymanapp / keyman / web / testing / regression-tests / test-builder.js View on Github external
}
});

fs.writeFileSync('./tests-generated.js', code);

//
// Run Karma with the generated tests
//

const Server = require('karma').Server;
const cfg = require('karma').config;

// Note: if karma.conf.js is invalid, then this will die with exit code 1
// without logging the error. The easiest way to see the error is to
// run `node_modules/bin/karma start karma.conf.js`
const karmaConfig = cfg.parseConfig(path.resolve('./karma.conf.js'), process.env.TEAMCITY_PROJECT_NAME ? {'reporters': ['teamcity']} : {});

let server = new Server(karmaConfig, function(exitCode) {
  console.log('Karma has exited with ' + exitCode)
  process.exit(exitCode)
});

server.start();
github SAP / webide-client-tools / example / scripts / karma_ci.js View on Github external
const { Server, config } = require("karma")
const path = require("path")

const karmaConfig = config.parseConfig(
  path.resolve(__dirname, "../karma.conf.js")
)

// CI only configurations
karmaConfig.singleRun = true
karmaConfig.browsers = ["ChromeHeadless"]

const server = new Server(karmaConfig, exitCode => {
  console.error(`Karma has exited with ${exitCode}`)
  process.exit(exitCode)
})
server.start()
github Financial-Times / origami-build-tools / lib / tasks / karma.js View on Github external
return Promise.all([constructPolyfillUrl(), getCustomKarmaConfig(config)]).then(values => {
		const polyfillUrl = values[0];

		// Add default Karma config to custom Karma config.
		const customKarmaConfig = values[1];
		const cfg = require('karma').config;
		Object.assign(customKarmaConfig, { basePath: config.cwd });
		const karmaConfig = cfg.parseConfig(null, customKarmaConfig);

		return new Promise((resolve, reject) => {
			const debug = Boolean(config.debug);

			if (debug) {
				karmaConfig.singleRun = false;
			}

			const { reporter, errors } = require('../plugins/listr-karma')();

			karmaConfig.files.unshift(polyfillUrl);
			karmaConfig.plugins.unshift(reporter);
			karmaConfig.reporters = ['listr'];

			const Server = require('karma').Server;
			const server = new Server(karmaConfig, exitCode => {
github maptalks / maptalks.js / gulpfile.js View on Github external
gulp.task('test', done => {
    // const karmaConfig = {
    //     configFile: path.join(__dirname, 'build/karma.test.config.js')
    // };
    let file = 'build/karma.test.config.js';
    if (options.coverage) {
        file = 'build/karma.cover.config.js';
    }
    const cfg = require('karma').config;
    const karmaConfig = cfg.parseConfig(path.join(__dirname, file));
    if (browsers.length > 0) {
        karmaConfig.browsers = browsers;
    }
    if (configBrowsers.indexOf('IE') >= 0) {
        let idx = -1;
        for (let i = 0; i < karmaConfig.files.length; i++) {
            if (karmaConfig.files[i].pattern.indexOf('test/core/ClassSpec.js') >= 0) {
                idx = i;
                break;
            }
        }
        if (idx >= 0) {
            karmaConfig.files.splice(idx, 1);
        }
    }
    if (configBrowsers === 'IE9') {
github niklasvh / html2canvas / karma.js View on Github external
const Server = require('karma').Server;
const cfg = require('karma').config;
const path = require('path');
const proxy = require('html2canvas-proxy');
const karmaConfig = cfg.parseConfig(path.resolve('./karma.conf.js'));
const server = new Server(karmaConfig, (exitCode) => {
    console.log('Karma has exited with ' + exitCode);
    process.exit(exitCode)
});

const fs = require('fs');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const filenamifyUrl = require('filenamify-url');

const mkdirp = require('mkdirp');
const screenshotFolder = './tmp/reftests';
const metadataFolder = './tmp/reftests/metadata';

mkdirp.sync(path.resolve(__dirname, screenshotFolder));
github DevExpress / devextreme-angular / gulpfile.js View on Github external
var getKarmaConfig = function(testsPath) {
    const preprocessors = {};
    preprocessors[testsPath] = [ 'webpack' ];
    return karmaConfig.parseConfig(path.resolve('./karma.conf.js'), {
        files: [{ pattern: testsPath, watched: false }],
        preprocessors: preprocessors
    });
};