Merge pull request #4463 from sgkim126/gulp-istanbul

gulp-istanbul 0.9.0 adds enforceThresholds function.
This commit is contained in:
Horiuchi_H
2015-05-29 15:38:02 +09:00
3 changed files with 79 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
// Type definitions for gulp-istanbul v0.8.1
// Project: https://github.com/SBoudrias/gulp-istanbul
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts"/>
declare module "gulp-istanbul" {
function GulpIstanbul(opts?: GulpIstanbul.Options): NodeJS.ReadWriteStream;
module GulpIstanbul {
export function hookRequire(): NodeJS.ReadWriteStream;
export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage;
export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream;
interface Options {
coverageVariable?: string;
includeUntested?: boolean;
embedSource?: boolean;
preserveComments?: boolean;
noCompact?: boolean;
noAutoWrap?: boolean;
codeGenerationOptions?: Object;
debug?: boolean;
walkDebug?: boolean;
}
interface Coverage {
lines: CoverageStats;
statements: CoverageStats;
functions: CoverageStats;
branches: CoverageStats;
}
interface CoverageStats {
total: number;
covered: number;
skipped: number;
pct: number;
}
interface ReportOptions {
dir?: string;
reporters?: string[];
reportOpts?: {dir?: string};
coverageVariable?: string;
}
}
export = GulpIstanbul;
}
+13
View File
@@ -29,4 +29,17 @@ gulp.task('test', function (cb) {
.pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned
.on('end', cb);
});
});
gulp.task('test', function (cb) {
gulp.src(['lib/**/*.js', 'main.js'])
.pipe(istanbul({includeUntested: true})) // Covering files
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(['test/*.html'])
.pipe(testFramework())
.pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) //
.on('end', cb);
});
});
+15 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for gulp-istanbul
// Type definitions for gulp-istanbul v0.9.0
// Project: https://github.com/SBoudrias/gulp-istanbul
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -12,6 +12,7 @@ declare module "gulp-istanbul" {
export function hookRequire(): NodeJS.ReadWriteStream;
export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage;
export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream;
export function enforceThresholds(opts?: ThresholdOptions): NodeJS.ReadWriteStream;
interface Options {
coverageVariable?: string;
@@ -45,7 +46,19 @@ declare module "gulp-istanbul" {
reportOpts?: {dir?: string};
coverageVariable?: string;
}
interface ThresholdOptions {
coverageVariable?: string;
thresholds?: { global?: Coverage|number; each?: Coverage|number };
}
interface CoverageOptions {
lines?: number;
statements?: number;
functions?: number;
branches?: number;
}
}
export = GulpIstanbul;
}
}