Skip to content

Commit a2b282e

Browse files
Juan Sotojamestalmage
Juan Soto
authored andcommitted
Close #410 PR. Print skip count in yellow for all reporters. Fixes #408
1 parent 37cd685 commit a2b282e

File tree

6 files changed

+62
-2
lines changed

6 files changed

+62
-2
lines changed

lib/reporters/mini.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function MiniReporter() {
1111

1212
this.passCount = 0;
1313
this.failCount = 0;
14+
this.skipCount = 0;
1415
this.rejectionCount = 0;
1516
this.exceptionCount = 0;
1617
this.finished = false;
@@ -27,7 +28,8 @@ MiniReporter.prototype.test = function (test) {
2728
var title;
2829

2930
if (test.skip) {
30-
title = chalk.cyan('- ' + test.title);
31+
title = chalk.yellow('- ' + test.title);
32+
this.skipCount++;
3133
} else if (test.error) {
3234
title = chalk.red(test.title);
3335
this.failCount++;
@@ -67,6 +69,10 @@ MiniReporter.prototype.finish = function () {
6769
status += ' ' + chalk.green(this.passCount, 'passed');
6870
}
6971

72+
if (this.skipCount > 0) {
73+
status += ' ' + chalk.yellow(this.skipCount, 'skipped');
74+
}
75+
7076
if (this.failCount > 0) {
7177
status += ' ' + chalk.red(this.failCount, 'failed');
7278
}

lib/reporters/tap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ TapReporter.prototype.finish = function () {
6767
'1..' + (this.api.passCount + this.api.failCount),
6868
'# tests ' + (this.api.passCount + this.api.failCount),
6969
'# pass ' + this.api.passCount,
70+
'# skip ' + this.api.skipCount,
7071
'# fail ' + (this.api.failCount + this.api.rejectionCount + this.api.exceptionCount),
7172
''
7273
];

lib/reporters/verbose.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ VerboseReporter.prototype.finish = function () {
6565
output += ' ' + chalk.green(this.api.passCount, plur('test', this.api.passCount), 'passed') + '\n';
6666
}
6767

68+
if (this.api.skipCount > 0) {
69+
output += ' ' + chalk.yellow(this.api.skipCount, plur('test', this.api.skipCount), 'skipped') + '\n';
70+
}
71+
6872
if (this.api.rejectionCount > 0) {
6973
output += ' ' + chalk.red(this.api.rejectionCount, 'unhandled', plur('rejection', this.api.rejectionCount)) + '\n';
7074
}

test/reporters/mini.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test('skipped test', function (t) {
5959

6060
var expectedOutput = [
6161
'',
62-
' ' + chalk.cyan('- skipped'),
62+
' ' + chalk.yellow('- skipped'),
6363
'',
6464
''
6565
].join('\n');
@@ -84,6 +84,36 @@ test('results with passing tests', function (t) {
8484
t.end();
8585
});
8686

87+
test('results with skipped tests', function (t) {
88+
var reporter = miniReporter();
89+
reporter.passCount = 0;
90+
reporter.skipCount = 1;
91+
reporter.failCount = 0;
92+
93+
var actualOutput = reporter.finish();
94+
var expectedOutput = [
95+
'',
96+
' ' + chalk.yellow('1 skipped'),
97+
''
98+
].join('\n');
99+
100+
t.is(actualOutput, expectedOutput);
101+
t.end();
102+
});
103+
104+
test('results with passing skipped tests', function (t) {
105+
var reporter = miniReporter();
106+
reporter.passCount = 1;
107+
reporter.skipCount = 1;
108+
109+
var output = reporter.finish().split('\n');
110+
111+
t.is(output[0], '');
112+
t.is(output[1], ' ' + chalk.green('1 passed') + ' ' + chalk.yellow('1 skipped'));
113+
t.is(output[2], '');
114+
t.end();
115+
});
116+
87117
test('results with passing tests and rejections', function (t) {
88118
var reporter = miniReporter();
89119
reporter.passCount = 1;

test/reporters/tap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ test('results', function (t) {
8181
var api = {
8282
passCount: 1,
8383
failCount: 2,
84+
skipCount: 1,
8485
rejectionCount: 3,
8586
exceptionCount: 4
8687
};
@@ -93,6 +94,7 @@ test('results', function (t) {
9394
'1..' + (api.passCount + api.failCount),
9495
'# tests ' + (api.passCount + api.failCount),
9596
'# pass ' + api.passCount,
97+
'# skip ' + api.skipCount,
9698
'# fail ' + (api.failCount + api.rejectionCount + api.exceptionCount),
9799
''
98100
].join('\n');

test/reporters/verbose.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ test('results with passing tests', function (t) {
165165
t.end();
166166
});
167167

168+
test('results with skipped tests', function (t) {
169+
var reporter = createReporter();
170+
reporter.api.passCount = 1;
171+
reporter.api.skipCount = 1;
172+
173+
var actualOutput = reporter.finish();
174+
var expectedOutput = [
175+
'',
176+
' ' + chalk.green('1 test passed'),
177+
' ' + chalk.yellow('1 test skipped'),
178+
''
179+
].join('\n');
180+
181+
t.is(actualOutput, expectedOutput);
182+
t.end();
183+
});
184+
168185
test('results with passing tests and rejections', function (t) {
169186
var reporter = createReporter();
170187
reporter.api.passCount = 1;

0 commit comments

Comments
 (0)