tscoverage/ts/npmts.tests.ts

44 lines
1.6 KiB
TypeScript
Raw Normal View History

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;
var istanbul = function () {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")])
2016-02-09 04:39:31 +00:00
// Covering files
.pipe(plugins.g.istanbul())
// Force `require` to return covered files
.pipe(plugins.g.istanbul.hookRequire());
return stream;
};
2016-02-09 04:39:31 +00:00
var mocha = function () {
var stream = plugins.gulp.src(["./test/test.js"])
2016-02-09 04:39:31 +00:00
.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 } }));
return stream;
};
2016-02-09 04:39:31 +00:00
var coveralls = function(){
2016-02-09 16:26:25 +00:00
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
.pipe(plugins.g.coveralls());
return stream;
};
2016-02-09 04:39:31 +00:00
istanbul().on("finish",function(){
mocha().on("finish",function(){
2016-02-09 16:26:25 +00:00
if(process.env.TRAVIS && config.coveralls){
coveralls().on("finish",function(){
done.resolve(config);
})
} else {
done.resolve(config);
2016-02-09 16:26:25 +00:00
}
2016-02-09 04:39:31 +00:00
})
});
2016-01-30 04:29:54 +00:00
return done.promise;
2016-01-30 03:57:24 +00:00
}
}