tscoverage/ts/npmts.tests.ts

43 lines
1.5 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(){
var stream = plugins.gulp.src("./coverage/**/lcov.info")
2016-02-09 04:39:31 +00:00
.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()
));
return stream;
};
2016-02-09 04:39:31 +00:00
istanbul().on("finish",function(){
mocha().on("finish",function(){
coveralls().on("finish",function(){
done.resolve(config);
})
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
}
}