tscoverage/dist/npmts.tests.js

46 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2016-03-12 09:21:16 +00:00
"use strict";
2016-02-19 23:53:23 +00:00
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
2016-02-22 21:22:39 +00:00
var done = plugins.Q.defer();
2016-02-19 23:53:23 +00:00
var config = configArg;
var istanbul = function () {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul())
.pipe(plugins.g.istanbul.hookRequire());
return stream;
};
var mocha = function () {
var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports())
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
return stream;
};
var coveralls = function () {
2016-02-22 21:22:39 +00:00
plugins.beautylog.log("now uploading coverage data to coveralls");
2016-02-19 23:53:23 +00:00
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
2016-03-12 09:21:16 +00:00
.pipe(plugins.g.coveralls())
.pipe(plugins.g.gFunction(function () {
2016-03-12 09:26:42 +00:00
plugins.beautylog.ok("Tests have passed and coverage data has been uploaded to Coveralls!");
2016-03-12 09:21:16 +00:00
}, "atEnd"));
2016-02-19 23:53:23 +00:00
return stream;
};
2016-03-12 09:21:16 +00:00
plugins.beautylog.log("now starting tests");
2016-02-19 23:53:23 +00:00
istanbul().on("finish", function () {
mocha().on("finish", function () {
2016-02-22 21:22:39 +00:00
if (plugins.smartenv.getEnv().isTravis && config.coveralls) {
2016-02-19 23:53:23 +00:00
coveralls().on("finish", function () {
done.resolve(config);
});
}
else {
2016-03-12 09:21:16 +00:00
plugins.beautylog.ok("Tests have passed!");
2016-02-19 23:53:23 +00:00
done.resolve(config);
}
});
});
return done.promise;
};