Skip to content

Commit 36bf87f

Browse files
committed
Merge pull request DefinitelyTyped#4463 from sgkim126/gulp-istanbul
gulp-istanbul 0.9.0 adds enforceThresholds function.
2 parents 70737c2 + 7094689 commit 36bf87f

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Type definitions for gulp-istanbul v0.8.1
2+
// Project: https://github.com/SBoudrias/gulp-istanbul
3+
// Definitions by: Asana <https://asana.com>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../node/node.d.ts"/>
7+
8+
declare module "gulp-istanbul" {
9+
function GulpIstanbul(opts?: GulpIstanbul.Options): NodeJS.ReadWriteStream;
10+
11+
module GulpIstanbul {
12+
export function hookRequire(): NodeJS.ReadWriteStream;
13+
export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage;
14+
export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream;
15+
16+
interface Options {
17+
coverageVariable?: string;
18+
includeUntested?: boolean;
19+
embedSource?: boolean;
20+
preserveComments?: boolean;
21+
noCompact?: boolean;
22+
noAutoWrap?: boolean;
23+
codeGenerationOptions?: Object;
24+
debug?: boolean;
25+
walkDebug?: boolean;
26+
}
27+
28+
interface Coverage {
29+
lines: CoverageStats;
30+
statements: CoverageStats;
31+
functions: CoverageStats;
32+
branches: CoverageStats;
33+
}
34+
35+
interface CoverageStats {
36+
total: number;
37+
covered: number;
38+
skipped: number;
39+
pct: number;
40+
}
41+
42+
interface ReportOptions {
43+
dir?: string;
44+
reporters?: string[];
45+
reportOpts?: {dir?: string};
46+
coverageVariable?: string;
47+
}
48+
}
49+
50+
export = GulpIstanbul;
51+
}

gulp-istanbul/gulp-istanbul-tests.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,17 @@ gulp.task('test', function (cb) {
2929
.pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned
3030
.on('end', cb);
3131
});
32+
});
33+
34+
gulp.task('test', function (cb) {
35+
gulp.src(['lib/**/*.js', 'main.js'])
36+
.pipe(istanbul({includeUntested: true})) // Covering files
37+
.pipe(istanbul.hookRequire())
38+
.on('finish', function () {
39+
gulp.src(['test/*.html'])
40+
.pipe(testFramework())
41+
.pipe(istanbul.writeReports({reporters: ['text']})) // Creating the reports after tests runned
42+
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) //
43+
.on('end', cb);
44+
});
3245
});

gulp-istanbul/gulp-istanbul.d.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for gulp-istanbul
1+
// Type definitions for gulp-istanbul v0.9.0
22
// Project: https://github.com/SBoudrias/gulp-istanbul
33
// Definitions by: Asana <https://asana.com>
44
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -12,6 +12,7 @@ declare module "gulp-istanbul" {
1212
export function hookRequire(): NodeJS.ReadWriteStream;
1313
export function summarizeCoverage(opts?: {coverageVariable?: string}): Coverage;
1414
export function writeReports(opts?: ReportOptions): NodeJS.ReadWriteStream;
15+
export function enforceThresholds(opts?: ThresholdOptions): NodeJS.ReadWriteStream;
1516

1617
interface Options {
1718
coverageVariable?: string;
@@ -45,7 +46,19 @@ declare module "gulp-istanbul" {
4546
reportOpts?: {dir?: string};
4647
coverageVariable?: string;
4748
}
49+
50+
interface ThresholdOptions {
51+
coverageVariable?: string;
52+
thresholds?: { global?: Coverage|number; each?: Coverage|number };
53+
}
54+
55+
interface CoverageOptions {
56+
lines?: number;
57+
statements?: number;
58+
functions?: number;
59+
branches?: number;
60+
}
4861
}
4962

5063
export = GulpIstanbul;
51-
}
64+
}

0 commit comments

Comments
 (0)