fix istanbul

This commit is contained in:
Philipp Kunz 2016-07-15 18:18:11 +02:00
parent 1202a68b01
commit 3ed7473066
6 changed files with 46 additions and 58 deletions

View File

@ -2,8 +2,10 @@ import "typings-global";
export import beautylog = require("beautylog"); export import beautylog = require("beautylog");
export declare let gulp: any; export declare let gulp: any;
export declare let g: { export declare let g: {
babel: any;
babelIstanbul: any;
gFunction: any; gFunction: any;
istanbul: any; injectModules: any;
mocha: any; mocha: any;
replace: any; replace: any;
sourcemaps: any; sourcemaps: any;

View File

@ -3,8 +3,10 @@ require("typings-global");
exports.beautylog = require("beautylog"); exports.beautylog = require("beautylog");
exports.gulp = require("gulp"); exports.gulp = require("gulp");
exports.g = { exports.g = {
babel: require("gulp-babel"),
babelIstanbul: require("gulp-babel-istanbul"),
gFunction: require("gulp-function"), gFunction: require("gulp-function"),
istanbul: require("gulp-istanbul"), injectModules: require("gulp-inject-modules"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
replace: require("gulp-replace"), replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),

43
dist/npmts.tests.js vendored
View File

@ -7,34 +7,26 @@ var npmts_promisechain_1 = require("./npmts.promisechain");
* *
* @returns {*} * @returns {*}
*/ */
var istanbul = function (configArg) { var mocha = function (configArg) {
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS..."); npmts_promisechain_1.npmtsOra.text("Instrumentalizing and testing transpiled JS");
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.sourcemaps.init()) .pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.istanbul()) // Covering files .pipe(plugins.g.babelIstanbul())
.pipe(plugins.g.babelIstanbul.hookRequire())
.pipe(plugins.g.sourcemaps.write()) .pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files .on("finish", function () {
.pipe(plugins.g.gFunction(function () { plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!"); .pipe(plugins.g.babel())
done.resolve(configArg); .pipe(plugins.g.injectModules())
}, "atEnd")); .pipe(plugins.g.mocha())
return done.promise; .pipe(plugins.g.babelIstanbul.writeReports())
}; .pipe(plugins.g.gFunction(function () {
/** plugins.beautylog.ok("Tested!");
* done.resolve(configArg);
* @returns {*} }, "atEnd"));
*/ });
var mocha = function (configArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
var 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; return done.promise;
}; };
var coverage = function (configArg) { var coverage = function (configArg) {
@ -63,8 +55,7 @@ exports.run = function (configArg) {
plugins.beautylog.log("-------------------------------------------------------\n" + plugins.beautylog.log("-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" + "*************************** TESTS: ***************************\n" +
"--------------------------------------------------------------"); "--------------------------------------------------------------");
istanbul(config) mocha(config)
.then(mocha)
.then(coverage) .then(coverage)
.then(function () { .then(function () {
done.resolve(config); done.resolve(config);

View File

@ -36,11 +36,12 @@
"early": "^2.0.13", "early": "^2.0.13",
"esdoc": "^0.4.7", "esdoc": "^0.4.7",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.4.0",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-function": "^1.3.6", "gulp-function": "^1.3.6",
"gulp-if": "^2.0.1", "gulp-if": "^2.0.1",
"gulp-istanbul": "^1.0.0", "gulp-inject-modules": "^1.0.0",
"gulp-jsdoc3": "^0.3.0",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^2.2.0",
"gulp-replace": "^0.5.4", "gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",

View File

@ -2,8 +2,10 @@ import "typings-global";
export import beautylog = require("beautylog"); export import beautylog = require("beautylog");
export let gulp = require("gulp"); export let gulp = require("gulp");
export let g = { export let g = {
babel: require("gulp-babel"),
babelIstanbul: require("gulp-babel-istanbul"),
gFunction: require("gulp-function"), gFunction: require("gulp-function"),
istanbul: require("gulp-istanbul"), injectModules: require("gulp-inject-modules"),
mocha: require("gulp-mocha"), mocha: require("gulp-mocha"),
replace: require("gulp-replace"), replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),

View File

@ -7,35 +7,26 @@ import {npmtsOra} from "./npmts.promisechain";
* *
* @returns {*} * @returns {*}
*/ */
let istanbul = function (configArg) { let mocha = function (configArg) {
npmtsOra.text("Instrumentalizing transpiled JS..."); npmtsOra.text("Instrumentalizing and testing transpiled JS");
npmtsOra.end(); // end npmtsOra for tests.
let done = plugins.Q.defer(); let done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
.pipe(plugins.g.sourcemaps.init()) .pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.istanbul()) // Covering files .pipe(plugins.g.babelIstanbul())
.pipe(plugins.g.babelIstanbul.hookRequire())
.pipe(plugins.g.sourcemaps.write()) .pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files .on("finish",function(){
.pipe(plugins.g.gFunction(function(){ plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!"); .pipe(plugins.g.babel())
done.resolve(configArg); .pipe(plugins.g.injectModules())
},"atEnd")); .pipe(plugins.g.mocha())
return done.promise; .pipe(plugins.g.babelIstanbul.writeReports())
}; .pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tested!");
/** done.resolve(configArg);
* },"atEnd"));
* @returns {*} });
*/
let mocha = function (configArg) {
let done = plugins.Q.defer();
npmtsOra.end(); // end npmtsOra for tests.
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; return done.promise;
}; };
@ -72,8 +63,7 @@ export let run = function(configArg) {
"--------------------------------------------------------------" "--------------------------------------------------------------"
); );
istanbul(config) mocha(config)
.then(mocha)
.then(coverage) .then(coverage)
.then(() => { .then(() => {
done.resolve(config); done.resolve(config);