2015-12-10 00:46:27 +03:00
|
|
|
var gulp = require('gulp');
|
|
|
|
|
|
|
|
var Server = require('karma').Server;
|
2016-06-16 15:44:14 +03:00
|
|
|
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
|
2015-12-10 00:46:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run test once and exit
|
|
|
|
*/
|
2016-05-20 22:56:10 +03:00
|
|
|
gulp.task('test', ['concatPrism', 'inlineTemplates', 'injectVersionFile'], function (done) {
|
2015-12-10 00:46:27 +03:00
|
|
|
new Server({
|
|
|
|
configFile: __dirname + '/../../karma.conf.js',
|
|
|
|
singleRun: true
|
2016-06-16 15:44:14 +03:00
|
|
|
}, karmaDone).start();
|
|
|
|
|
|
|
|
function karmaDone (exitCode) {
|
|
|
|
remapCoverage(done, exitCode);
|
|
|
|
}
|
2015-12-10 00:46:27 +03:00
|
|
|
});
|
2016-06-16 15:44:14 +03:00
|
|
|
|
|
|
|
function remapCoverage(done, statusCode) {
|
|
|
|
console.log('Remapping coverage to TypeScript format...');
|
|
|
|
gulp.src('coverage/**/coverage-final.json')
|
2016-06-16 16:43:58 +03:00
|
|
|
.pipe(remapIstanbul({
|
|
|
|
reports: {
|
|
|
|
'lcovonly': 'coverage/lcov.info',
|
|
|
|
'text-summary': 'coverage/text-summary.txt',
|
|
|
|
'html': 'coverage'
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.on('finish', function () {
|
|
|
|
console.log('Remapping done!');
|
|
|
|
console.log(cat('coverage/text-summary.txt').stdout);
|
|
|
|
console.log('Test Done with exit code: ' + statusCode);
|
|
|
|
if (process.env.TRAVIS) {
|
|
|
|
console.log('uploading to coveralls')
|
|
|
|
var out = cat('coverage/lcov.info').exec('coveralls');
|
|
|
|
if (out.code !== 0) {
|
|
|
|
console.warn('Failed upload to coveralls');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done(statusCode);
|
|
|
|
});
|
2016-06-16 15:44:14 +03:00
|
|
|
};
|