redoc/build/tasks/test.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-12-10 00:46:27 +03:00
var gulp = require('gulp');
2016-06-23 11:34:49 +03:00
var runSequence = require('run-sequence');
2015-12-10 00:46:27 +03:00
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
2016-06-23 11:34:49 +03:00
gulp.task('prepare-test', function(cb) {
return runSequence(
'clean',
'transpile',
'concatPrism',
cb
);
})
2015-12-10 00:46:27 +03:00
/**
* Run test once and exit
*/
2016-06-23 11:34:49 +03:00
gulp.task('test', ['prepare-test'], 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
};