Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task("test-unit-dev", "Execute all unit tests continuously (watches files)", (callback) =>{
return new KarmaServer({
configFile: karmaConfigFilePath, // necessary otherwise the file is not resolved correctly
singleRun: false
}, callback).start();
});
let resolve, reject
// eslint-disable-next-line
let promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
let callback = code => {
if (code === 0) return resolve()
let err = Error(`Exit ${code}`)
err.code = code
reject(err)
}
let server = new Server(config, callback)
server.completion = promise
return server
}
}
if (isArgv('--cov')) {
testConfig.preprocessors = {
'src/**/*.js': 'coverage'
};
testConfig.coverageReporter = {
type : 'html',
dir : 'coverage/'
};
testConfig.reporters = ['coverage'];
}
console.log('Running tests...');
var server = new karma.Server(testConfig, function(exitCode) {
if (!exitCode) {
console.log('\tTests ran successfully.\n');
complete();
} else {
process.exit(exitCode);
}
});
server.start();
});
gulp.task('karma', ['lint'], function (done) {
let server = new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: !Boolean(argv['keep-browser-open']),
client: {
captureConsole: Boolean(argv['capture-console'])
}
});
server.on('browser_error', function (browser, err) {
console.log('Karma Run Failed: ' + err.message);
throw err;
});
server.on('run_complete', function (browsers, results) {
if (results.failed) {
return done(new Error('Karma: Tests Failed'));
}
gulp.task('watch', () => {
gulp.start(['test:node'])
gulp.watch(['lib/**/*.js', 'test/**/*.js'], ['test:node'])
new KarmaServer({
configFile: path.join(__dirname, 'karma.conf.js'),
}).start()
})
gulp.task('test:js', 'Runs all tests', function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: argv.debug ? false : true
}, done).start();
});
gulp.task('test', function (done) {
new karmaServer({
configFile: require('path').resolve('karma.conf.js'),
singleRun: true
}, done).start();
});
var karmaConfig = {
configFile: __dirname + '/karma.conf.js',
action: params.isWatch ? 'watch' : 'run',
singleRun: true
};
if (params.coverageReporter) {
karmaConfig.coverageReporter = params.coverageReporter;
}
if (params.reporters) {
karmaConfig.reporters = params.reporters;
}
new karma.Server(karmaConfig).start();
}
gulp.task('tests:unit', function (done) {
var server = new KarmaServer({
configFile: PROJECT_PATH.tests + '/karma.conf.js',
singleRun: true
}, done);
server.start();
});
gulp.task('test-browser', ['dist-test'], function(done) {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: false,
autoWatchBatchDelay: 1000,
}, done).start();
gulp.watch(['src/**/*.ts', 'test/*.ts'], ['dist-test']);
});