now has better coverage failure
This commit is contained in:
@ -40,6 +40,8 @@ export var run = function(configArg){
|
||||
config.coveralls ? void(0) : config.coveralls = false;
|
||||
doPublish() ? void(0) : config.coveralls = false;
|
||||
|
||||
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
|
||||
|
||||
// handle docs
|
||||
config.docs ? void(0) : config.docs = {};
|
||||
config.docs.publish ? void(0) : config.docs.publish = false;
|
||||
|
@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
||||
paths.distDir = plugins.path.join(paths.cwd,"dist/");
|
||||
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
|
||||
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
||||
paths.coverageDir = plugins.path.join(paths.cwd,"coverage/");
|
||||
|
||||
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
|
||||
|
||||
|
@ -21,6 +21,7 @@ export let Q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
export let smartci = require("smartci");
|
||||
export let smartcli = require("smartcli");
|
||||
export let smartcov = require("smartcov");
|
||||
export let smartenv = require("smartenv");
|
||||
export let smartfile = require("smartfile");
|
||||
export let smartpath = require("smartpath");
|
@ -8,7 +8,6 @@ import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||
export let run = function(configArg){
|
||||
let done = plugins.Q.defer();
|
||||
let config = configArg;
|
||||
|
||||
let promiseArray = [];
|
||||
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0);
|
||||
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
|
||||
|
@ -14,27 +14,62 @@ export let publishCoverage = function(configArg){
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export var run = function(configArg) {
|
||||
var done = plugins.Q.defer();
|
||||
var config = configArg;
|
||||
var istanbul = function () {
|
||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
||||
// Covering files
|
||||
.pipe(plugins.g.istanbul())
|
||||
// Force `require` to return covered files
|
||||
.pipe(plugins.g.istanbul.hookRequire());
|
||||
return stream;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @returns {*}
|
||||
*/
|
||||
let istanbul = function (configArg) {
|
||||
let done = plugins.Q.defer();
|
||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
||||
.pipe(plugins.g.istanbul()) // Covering files
|
||||
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
||||
.pipe(plugins.g.gFunction(function(){
|
||||
done.resolve(configArg);
|
||||
},"atEnd"));
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var mocha = function () {
|
||||
var stream = 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%
|
||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
||||
return stream;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @returns {*}
|
||||
*/
|
||||
let mocha = function (configArg) {
|
||||
let done = plugins.Q.defer();
|
||||
let stream = plugins.gulp.src(["./test/test.js"])
|
||||
.pipe(plugins.g.mocha())
|
||||
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
||||
.pipe(plugins.g.gFunction(function(){
|
||||
plugins.beautylog.ok("Tests have passed!");
|
||||
done.resolve(configArg);
|
||||
},"atEnd"));
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let coverage = function(configArg){
|
||||
let done = plugins.Q.defer();
|
||||
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
|
||||
.then(function(percentageArg){
|
||||
if (percentageArg >= configArg.coverageTreshold){
|
||||
plugins.beautylog.ok(
|
||||
"your coverage of " + percentageArg + "% " + "is within your treshold of " +
|
||||
configArg.coverageTreshold + "%"
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.warn(
|
||||
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
|
||||
configArg.coverageTreshold + "%"
|
||||
);
|
||||
plugins.beautylog.error("exiting due to coverage failure");
|
||||
process.exit(1);
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let run = function(configArg) {
|
||||
let done = plugins.Q.defer();
|
||||
let config = configArg;
|
||||
|
||||
plugins.beautylog.log("now starting tests");
|
||||
console.log(
|
||||
@ -44,11 +79,10 @@ export var run = function(configArg) {
|
||||
"***************************\n" +
|
||||
"--------------------------------------------------------------"
|
||||
);
|
||||
istanbul().on("finish",function(){
|
||||
mocha().on("finish",function(){
|
||||
plugins.beautylog.ok("Tests have passed!");
|
||||
done.resolve(config);
|
||||
})
|
||||
});
|
||||
|
||||
istanbul(config)
|
||||
.then(mocha)
|
||||
.then(coverage)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
};
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||
"istanbul": "registry:dt/istanbul#0.4.0+20160316155526",
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user