diff --git a/gulp-istanbul/gulp-istanbul-0.8.1.d.ts b/gulp-istanbul/gulp-istanbul-0.8.1.d.ts new file mode 100644 index 000000000..3a10dfdba --- /dev/null +++ b/gulp-istanbul/gulp-istanbul-0.8.1.d.ts @@ -0,0 +1,51 @@ +// Type definitions for gulp-istanbul v0.8.1 +// Project: https://github.com/SBoudrias/gulp-istanbul +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; +} diff --git a/gulp-istanbul/gulp-istanbul-tests.ts b/gulp-istanbul/gulp-istanbul-tests.ts index 7f2327d07..0d64b53d0 100644 --- a/gulp-istanbul/gulp-istanbul-tests.ts +++ b/gulp-istanbul/gulp-istanbul-tests.ts @@ -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); + }); }); \ No newline at end of file diff --git a/gulp-istanbul/gulp-istanbul.d.ts b/gulp-istanbul/gulp-istanbul.d.ts index bf7a13bb0..d917d64b1 100644 --- a/gulp-istanbul/gulp-istanbul.d.ts +++ b/gulp-istanbul/gulp-istanbul.d.ts @@ -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 // 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; -} \ No newline at end of file +}