2016-01-30 03:57:24 +00:00
|
|
|
/// <reference path="./index.ts" />
|
|
|
|
module NpmtsTests {
|
2016-02-09 04:46:55 +00:00
|
|
|
export var run = function(configArg) {
|
2016-01-30 04:29:54 +00:00
|
|
|
var done = plugins.q.defer();
|
2016-02-09 04:46:55 +00:00
|
|
|
var config = configArg;
|
2016-02-09 04:39:31 +00:00
|
|
|
plugins.gulp.task('istanbul', function () {
|
|
|
|
return plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")])
|
|
|
|
// Covering files
|
|
|
|
.pipe(plugins.g.istanbul())
|
|
|
|
// Force `require` to return covered files
|
|
|
|
.pipe(plugins.g.istanbul.hookRequire());
|
2016-01-30 03:57:24 +00:00
|
|
|
});
|
2016-02-09 04:39:31 +00:00
|
|
|
|
|
|
|
plugins.gulp.task('mocha', function () {
|
|
|
|
return plugins.gulp.src(['test/test.js'])
|
|
|
|
.pipe(plugins.g.mocha())
|
|
|
|
// Creating the reports after tests ran
|
|
|
|
.pipe(plugins.g.istanbul.writeReports())
|
|
|
|
// Enforce a coverage of at least 90%
|
2016-02-09 05:01:32 +00:00
|
|
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
2016-02-09 04:39:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
plugins.gulp.task("coveralls",function(){
|
|
|
|
return plugins.gulp.src('coverage/**/lcov.info')
|
|
|
|
.pipe(plugins.g.if(
|
2016-02-09 04:46:55 +00:00
|
|
|
(process.env.TRAVIS && config.coveralls),
|
2016-02-09 04:39:31 +00:00
|
|
|
plugins.g.coveralls()
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
plugins.gulp.task("test",function(){
|
|
|
|
plugins.g.sequence("istanbul","mocha","coveralls",function(){
|
|
|
|
done.resolve();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
plugins.gulp.start.apply(plugins.gulp, ['test']);
|
2016-01-30 04:29:54 +00:00
|
|
|
return done.promise;
|
2016-01-30 03:57:24 +00:00
|
|
|
}
|
|
|
|
}
|