Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function karmaPromise(config) {
// peel off the configured arrays so can concat them
const configPlugins = config.plugins;
const configFrameworks = config.frameworks;
const configReporters = config.reporters;
delete config.plugins;
delete config.frameworks;
delete config.reporters;
const karmaConfig = karma.config.parseConfig(path.resolve(karmaConfigPath), config);
karmaConfig.logLevel = options.verbose ? 'DEBUG' : karmaConfig.logLevel;
karmaConfig.plugins = catArr(karmaConfig.plugins, configPlugins);
karmaConfig.frameworks = catArr(karmaConfig.frameworks, configFrameworks);
karmaConfig.reporters = catArr(karmaConfig.reporters, configReporters);
return new Promise(function startServer(resolve) {
var server = new karma.Server(karmaConfig, function karmaExit(exitCode) {
resolve(exitCode); // eslint-disable-line no-process-exit
});
server.start();
});
});
};
/*
* In local config, only run tests using phantom js. No code coverage reports applied
*/
const webpack = require('webpack');
const path = require('path');
const karma = require('karma');
const argv = require('minimist')(process.argv.slice(2));
// load our current karma config file
const { preprocessors: defaultPreprocessors,
files: defaultFiles,
basePath,
webpack: defaultWebpack,
webpackServer } = karma.config.parseConfig(path.resolve('config/karma.js'));
let files = defaultFiles;
let preprocessors = defaultPreprocessors;
// if "--file" present, run only tests for that file and enable sourcemaps
if (argv.file) {
const testFile = path.resolve(argv.file);
files = [...defaultFiles.slice(0, defaultFiles.length - 1), testFile];
preprocessors = Object.keys(defaultPreprocessors).reduce( (res, key) => {
if (key === defaultFiles[defaultFiles.length - 1].pattern) {
res[testFile] = [...defaultPreprocessors[key], 'sourcemap'];
} else {
res[key] = defaultPreprocessors[key];
}
return res;
}, {});
console.log(`Running just the tests in ${testFile}`);
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);
}
}
logger
.error(`Pact proxy path is invalid. Expected format is base/provider-name/api-path.`);
}
})
.on('connect', () => {
logger
.info(
`Pact proxy server successfully started on http://localhost:${ports[ports.length - 1]}`
);
})
.listen(ports[ports.length - 1], 'localhost');
// for use by consuming app
pactServers.savePactProxyServer(`http://localhost:${ports[ports.length - 1]}`);
const karmaConfigUtil = karma.config;
const karmaConfigPath = configResolver.resolve(command, argv);
const karmaConfig = karmaConfigUtil.parseConfig(karmaConfigPath);
let lintResult;
const onRunStart = () => {
lintResult = tsLinter.lintSync();
};
const onRunComplete = () => {
if (lintResult && lintResult.exitCode > 0) {
// Pull the logger out of the execution stream to let it print
// after karma's coverage reporter.
setTimeout(() => {
logger.error('Process failed due to linting errors:');
lintResult.errors.forEach(error => logger.error(error));
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 run = (specFile) => {
const configPath = path.resolve(`${__dirname}${path.sep}karma.conf.js`);
const karmaConfig = karma.config.parseConfig(configPath, { files: [specFile], port: 9876 } );
var server = new karma.Server(karmaConfig, function(exitCode) {
console.info('Karma Server has exited with ' + exitCode);
});
let runStart;
server.on('run_start', browsers => {
runStart = new Date();
});
return new Promise((resolve) => {
let isBrowserValid = false;
server.start();
server.on('browser_register', browsers => {
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';
#!/usr/bin/env node
'use strict';
const { readdirSync, statSync } = require('fs');
const { Server, stopper } = require('karma');
const { parseConfig } = require('karma').config;
const { resolve: resolvePath } = require('path');
const { join } = require('path');
const configFile = join(__dirname, '..', process.argv[2]);
const integrationTests = join(__dirname, '..', 'test', 'integration', 'spec');
const dockerIntegrationTests = join(__dirname, '..', 'test', 'integration', 'spec', 'docker');
const isDocker = require('is-docker')();
const DockerProxyServer = require('../docker/dockerProxyServer');
function getTestPaths(path) {
var stat = statSync(path);
if (stat && stat.isDirectory()) {
return readdirSync(path).reduce((files, file) => {
return files.concat(getTestPaths(`${path}/${file}`));
}, []);
}
var gulp = require('gulp');
var runSequence = require("run-sequence");
var path = require('path');
var typescript = require('gulp-typescript');
var tslint = require('gulp-tslint');
var replace = require('gulp-replace');
var shell = require('gulp-shell');
var sourcemaps = require('gulp-sourcemaps');
var jasmine = require('gulp-jasmine');
var jasmineReporters = require('jasmine-reporters');
var del = require('del');
var mergeJson = require('gulp-merge-json');
var karmaServer = require('karma').Server;
var karmaConfig = require('karma').config;
var buildConfig = require('./build.config');
var header = require('gulp-header');
var fs = require('fs');
//------------Main------------
gulp.task('build', [
'build.tools',
'build.components',
'build.examples'
]
);
gulp.task('default', ['build']);