From d1f8d191863408ee12f9546e47d19368a38bb7ad Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 16 May 2016 20:50:38 +0800 Subject: [PATCH 01/27] pass failing metadata to results --- lib/runner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/runner.js b/lib/runner.js index 909db8a6f..f34632e14 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -138,7 +138,8 @@ Runner.prototype._addTestResult = function (result) { error: result.reason, type: test.metadata.type, skip: test.metadata.skipped, - todo: test.metadata.todo + todo: test.metadata.todo, + failing: test.metadata.failing }; this.results.push(result); From 732e1c0e5babf07430bb139196da5c679dbd1d0c Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 16 May 2016 20:51:09 +0800 Subject: [PATCH 02/27] modify mini reporter for failing test output --- lib/reporters/mini.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 8c04c2b4b..624ed8cb5 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -50,6 +50,7 @@ MiniReporter.prototype.start = function () { MiniReporter.prototype.reset = function () { this.clearInterval(); this.passCount = 0; + this.failingCount = 0; this.failCount = 0; this.skipCount = 0; this.todoCount = 0; @@ -80,6 +81,9 @@ MiniReporter.prototype.test = function (test) { this.failCount++; } else { this.passCount++; + if (test.failing) { + this.failCount++; + } } if (test.todo || test.skip) { @@ -102,7 +106,7 @@ MiniReporter.prototype._test = function (test) { var PADDING = 1; var title = cliTruncate(test.title, process.stdout.columns - SPINNER_WIDTH - PADDING); - if (test.error) { + if (test.error || test.failing) { title = colors.error(test.title); } @@ -120,6 +124,7 @@ MiniReporter.prototype.unhandledError = function (err) { MiniReporter.prototype.reportCounts = function (time) { var lines = [ this.passCount > 0 ? '\n ' + colors.pass(this.passCount, 'passed') : '', + this.failingCount > 0 ? '\n ' + colors.error(this.failingCount, 'failing') : '', this.failCount > 0 ? '\n ' + colors.error(this.failCount, 'failed') : '', this.skipCount > 0 ? '\n ' + colors.skip(this.skipCount, 'skipped') : '', this.todoCount > 0 ? '\n ' + colors.todo(this.todoCount, 'todo') : '' @@ -198,6 +203,22 @@ MiniReporter.prototype.finish = function (runStatus) { }); } + if (this.failingCount > 0) { + runStatus.errors.forEach(function (test) { + if (!test.failing) { + return; + } + + i++; + + var title = test.title; + var description = JSON.stringify(test); + + status += '\n\n\n ' + colors.error(i + '.', title) + '\n'; + status += colors.stack(description); + }); + } + return status + '\n'; }; From 269007a2d74e1c2ed97e4752ef4f7e3d18ef3303 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Tue, 17 May 2016 17:57:30 +0800 Subject: [PATCH 03/27] rename variable && reorder output --- lib/reporters/mini.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 624ed8cb5..8c74b2087 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -50,7 +50,7 @@ MiniReporter.prototype.start = function () { MiniReporter.prototype.reset = function () { this.clearInterval(); this.passCount = 0; - this.failingCount = 0; + this.knownFailureCount = 0; this.failCount = 0; this.skipCount = 0; this.todoCount = 0; @@ -82,7 +82,7 @@ MiniReporter.prototype.test = function (test) { } else { this.passCount++; if (test.failing) { - this.failCount++; + this.knownFailureCount++; } } @@ -124,7 +124,7 @@ MiniReporter.prototype.unhandledError = function (err) { MiniReporter.prototype.reportCounts = function (time) { var lines = [ this.passCount > 0 ? '\n ' + colors.pass(this.passCount, 'passed') : '', - this.failingCount > 0 ? '\n ' + colors.error(this.failingCount, 'failing') : '', + this.knownFailureCount > 0 ? '\n ' + colors.error(this.knownFailureCount, 'known failure') : '', this.failCount > 0 ? '\n ' + colors.error(this.failCount, 'failed') : '', this.skipCount > 0 ? '\n ' + colors.skip(this.skipCount, 'skipped') : '', this.todoCount > 0 ? '\n ' + colors.todo(this.todoCount, 'todo') : '' @@ -161,6 +161,22 @@ MiniReporter.prototype.finish = function (runStatus) { var i = 0; + if (this.knownFailureCount > 0) { + runStatus.errors.forEach(function (test) { + if (!test.failing) { + return; + } + + i++; + + var title = test.title; + var description = JSON.stringify(test); + + status += '\n\n\n ' + colors.error(i + '.', title) + '\n'; + status += colors.stack(description); + }); + } + if (this.failCount > 0) { runStatus.errors.forEach(function (test) { if (!test.error || !test.error.message) { @@ -203,22 +219,6 @@ MiniReporter.prototype.finish = function (runStatus) { }); } - if (this.failingCount > 0) { - runStatus.errors.forEach(function (test) { - if (!test.failing) { - return; - } - - i++; - - var title = test.title; - var description = JSON.stringify(test); - - status += '\n\n\n ' + colors.error(i + '.', title) + '\n'; - status += colors.stack(description); - }); - } - return status + '\n'; }; From cb01bd3e885931573961dc19b60a97d4fd7681a2 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Tue, 17 May 2016 17:59:15 +0800 Subject: [PATCH 04/27] do not output description --- lib/reporters/mini.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 8c74b2087..8442c9606 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -170,10 +170,11 @@ MiniReporter.prototype.finish = function (runStatus) { i++; var title = test.title; - var description = JSON.stringify(test); + // var description = JSON.stringify(test); status += '\n\n\n ' + colors.error(i + '.', title) + '\n'; - status += colors.stack(description); + // TODO output description with link + // status += colors.stack(description); }); } From 452cb41613b18a60fb8bf724e30188b2c7a9dda6 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Tue, 17 May 2016 23:43:59 +0800 Subject: [PATCH 05/27] add knownFailure to run-status --- lib/run-status.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/run-status.js b/lib/run-status.js index 62d18a326..7512d9fb1 100644 --- a/lib/run-status.js +++ b/lib/run-status.js @@ -22,12 +22,14 @@ function RunStatus(opts) { this.rejectionCount = 0; this.exceptionCount = 0; this.passCount = 0; + this.knownFailureCount = 0; this.skipCount = 0; this.todoCount = 0; this.failCount = 0; this.fileCount = 0; this.testCount = 0; this.previousFailCount = 0; + this.knownFailures = []; this.errors = []; this.stats = []; this.tests = []; @@ -123,6 +125,10 @@ RunStatus.prototype.handleTest = function (test) { this.errors.push(test); } + if (this.failing) { + this.knownFailures.push(test); + } + this.emit('test', test, this); }; @@ -172,6 +178,7 @@ RunStatus.prototype.processResults = function (results) { this.tests = flatten(this.tests); this.passCount = sum(this.stats, 'passCount'); + this.knownFailureCount = sum(this.stats, 'knownFailureCount'); this.skipCount = sum(this.stats, 'skipCount'); this.todoCount = sum(this.stats, 'todoCount'); this.failCount = sum(this.stats, 'failCount'); From 05a6c99863e4d712ffd83d932a055a71e643163c Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Wed, 18 May 2016 00:07:36 +0800 Subject: [PATCH 06/27] fix mistake in run-status --- lib/run-status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/run-status.js b/lib/run-status.js index 7512d9fb1..56c0c5763 100644 --- a/lib/run-status.js +++ b/lib/run-status.js @@ -125,7 +125,7 @@ RunStatus.prototype.handleTest = function (test) { this.errors.push(test); } - if (this.failing) { + if (test.failing) { this.knownFailures.push(test); } From d0e5dc2dcc484089f44764b526bc12f59f1656fb Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Thu, 19 May 2016 11:26:05 +0800 Subject: [PATCH 07/27] add failing output in verbose reporter --- lib/reporters/verbose.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 05cd41134..a65c75bcb 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -33,6 +33,10 @@ VerboseReporter.prototype.test = function (test, runStatus) { return ' ' + colors.skip('- ' + test.title); } + if (test.failing) { + return ' ' + colors.error(test.title + ' ' + colors.error(test.error.message)); + } + if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { return undefined; } @@ -71,6 +75,7 @@ VerboseReporter.prototype.finish = function (runStatus) { var output = '\n'; var lines = [ + runStatus.knownFailureCount > 0 ? ' ' + colors.error(runStatus.knownFailureCount, plur('test', runStatus.knownFailureCount), 'known failure') : '', runStatus.failCount > 0 ? ' ' + colors.error(runStatus.failCount, plur('test', runStatus.failCount), 'failed') : ' ' + colors.pass(runStatus.passCount, plur('test', runStatus.passCount), 'passed'), @@ -86,9 +91,16 @@ VerboseReporter.prototype.finish = function (runStatus) { output += lines.join('\n'); } - if (runStatus.failCount > 0) { - var i = 0; + var i = 0; + if (runStatus.knownFailureCount > 0) { + runStatus.knownFailures.forEach(function (test) { + i++; + output += '\n\n\n ' + colors.error(i + '.', test.title) + '\n'; + }); + } + + if (runStatus.failCount > 0) { runStatus.tests.forEach(function (test) { if (!(test.error && test.error.message)) { return; From bdb533353da32f7f3f33fe9e90fa913c9b3f5c5e Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:14:59 +0800 Subject: [PATCH 08/27] push a test to known failure only when it marked as failing and it fails So after flipping the test result, reason need to be deleted if the flipped result is passed. --- lib/run-status.js | 2 +- lib/test.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/run-status.js b/lib/run-status.js index 56c0c5763..7cbebd4c8 100644 --- a/lib/run-status.js +++ b/lib/run-status.js @@ -125,7 +125,7 @@ RunStatus.prototype.handleTest = function (test) { this.errors.push(test); } - if (test.failing) { + if (test.failing && !test.error) { this.knownFailures.push(test); } diff --git a/lib/test.js b/lib/test.js index 84d698556..d682e4bd6 100644 --- a/lib/test.js +++ b/lib/test.js @@ -190,7 +190,9 @@ Test.prototype._result = function () { var passed = reason === undefined; if (this.metadata.failing) { passed = !passed; - if (!passed) { + if (passed) { + reason = undefined; + } else { reason = new Error('Test was expected to fail, but succeeded, you should stop marking the test as failing'); } } From 1d02fa5072630fe403e9a16f6a1657bd14a49015 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:15:48 +0800 Subject: [PATCH 09/27] integrate runStatus.knownFailure for output --- lib/reporters/mini.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 8442c9606..82c7d474b 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -162,11 +162,7 @@ MiniReporter.prototype.finish = function (runStatus) { var i = 0; if (this.knownFailureCount > 0) { - runStatus.errors.forEach(function (test) { - if (!test.failing) { - return; - } - + runStatus.knownFailures.forEach(function (test) { i++; var title = test.title; From 97b99180d42ddeea90cd77a5a8078868174f7ae6 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:16:09 +0800 Subject: [PATCH 10/27] and some test --- test/reporters/mini.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 2889c5296..60ea5bb1f 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -55,6 +55,26 @@ test('passing test', function (t) { t.end(); }); +test('known failure test', function (t) { + var reporter = miniReporter(); + + var actualOutput = reporter.test({ + title: 'known failure', + failing: true + }); + + var expectedOutput = [ + ' ', + ' ' + graySpinner + ' ' + chalk.red('known failure'), + '', + ' ' + chalk.green('1 passed'), + ' ' + chalk.red('1 known failure') + ].join('\n'); + + t.is(actualOutput, expectedOutput); + t.end(); +}); + test('failing test', function (t) { var reporter = miniReporter(); @@ -76,6 +96,28 @@ test('failing test', function (t) { t.end(); }); +test('failed known failure test', function (t) { + var reporter = miniReporter(); + + var actualOutput = reporter.test({ + title: 'known failure', + failing: true, + error: { + message: 'Test was expected to fail, but succeeded, you should stop marking the test as failing' + } + }); + + var expectedOutput = [ + ' ', + ' ' + graySpinner + ' ' + chalk.red('known failure'), + '', + ' ' + chalk.red('1 failed') + ].join('\n'); + + t.is(actualOutput, expectedOutput); + t.end(); +}); + test('passing test after failing', function (t) { var reporter = miniReporter(); From 53b93024cdc9b0570edcfa943974c847dbd74f8b Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:18:26 +0800 Subject: [PATCH 11/27] fix verbose reporter --- lib/reporters/verbose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index a65c75bcb..06932a2f0 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -34,7 +34,7 @@ VerboseReporter.prototype.test = function (test, runStatus) { } if (test.failing) { - return ' ' + colors.error(test.title + ' ' + colors.error(test.error.message)); + return ' ' + colors.error(test.title); } if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { From 7969dcafce2dbf3108c2fc49faad0369e6a1aef0 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:23:00 +0800 Subject: [PATCH 12/27] add test for verbose reporter --- test/reporters/verbose.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index 8eca900e9..8a6e50c7b 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -89,6 +89,20 @@ test('don\'t display test title if there is only one anonymous test', function ( t.end(); }); +test('known failure test', function (t) { + var reporter = createReporter(); + + var actualOutput = reporter.test({ + title: 'known failure', + failing: true + }, createRunStatus()); + + var expectedOutput = ' ' + chalk.red('known failure'); + + t.is(actualOutput, expectedOutput); + t.end(); +}); + test('failing test', function (t) { var reporter = createReporter(); From 7f7160dca85970358e08ded2a2a66acee10d0daf Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:28:00 +0800 Subject: [PATCH 13/27] fix tests after remove reason for known failure --- test/test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 3f45a329a..9edcc441f 100644 --- a/test/test.js +++ b/test/test.js @@ -622,13 +622,12 @@ test('failing tests should fail', function (t) { t.end(); }); -test('failing callback tests should end with an error', function (t) { +test('failing callback tests should end without error', function (t) { var err = new Error('failed'); ava.cb.failing(function (a) { a.end(err); }).run().then(function (result) { t.is(result.passed, true); - t.is(result.reason, err); t.end(); }); }); From 1352138db227cbcef429b536e8fbea741ec9de86 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 17:49:12 +0800 Subject: [PATCH 14/27] enhance coverage for reporters/mini --- lib/reporters/mini.js | 2 +- test/reporters/mini.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 82c7d474b..6978f9c21 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -168,7 +168,7 @@ MiniReporter.prototype.finish = function (runStatus) { var title = test.title; // var description = JSON.stringify(test); - status += '\n\n\n ' + colors.error(i + '.', title) + '\n'; + status += '\n\n\n ' + colors.error(i + '.', title); // TODO output description with link // status += colors.stack(description); }); diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 60ea5bb1f..5103a69c0 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -206,6 +206,29 @@ test('results with passing tests', function (t) { t.end(); }); +test('results with passing known failure tests', function (t) { + var reporter = miniReporter(); + reporter.passCount = 1; + reporter.knownFailureCount = 1; + reporter.failCount = 0; + + var runStatus = { + knownFailures: [{title: 'known failure', failing: true}] + }; + var actualOutput = reporter.finish(runStatus); + var expectedOutput = [ + '\n ' + chalk.green('1 passed') + time, + ' ' + chalk.red('1 known failure'), + '', + '', + ' ' + chalk.red('1. known failure'), + '' + ].join('\n'); + + t.is(actualOutput, expectedOutput); + t.end(); +}); + test('results with skipped tests', function (t) { var reporter = miniReporter(); reporter.passCount = 0; From d618a6a812b8490019451f98f53ff807e76302b4 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 18:03:28 +0800 Subject: [PATCH 15/27] enhance coverage for reporter/verbose --- lib/reporters/verbose.js | 2 +- test/reporters/verbose.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 06932a2f0..ac1d4b5aa 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -75,10 +75,10 @@ VerboseReporter.prototype.finish = function (runStatus) { var output = '\n'; var lines = [ - runStatus.knownFailureCount > 0 ? ' ' + colors.error(runStatus.knownFailureCount, plur('test', runStatus.knownFailureCount), 'known failure') : '', runStatus.failCount > 0 ? ' ' + colors.error(runStatus.failCount, plur('test', runStatus.failCount), 'failed') : ' ' + colors.pass(runStatus.passCount, plur('test', runStatus.passCount), 'passed'), + runStatus.knownFailureCount > 0 ? ' ' + colors.error(runStatus.knownFailureCount, plur('test', runStatus.knownFailureCount), 'known failure') : '', runStatus.skipCount > 0 ? ' ' + colors.skip(runStatus.skipCount, plur('test', runStatus.skipCount), 'skipped') : '', runStatus.todoCount > 0 ? ' ' + colors.todo(runStatus.todoCount, plur('test', runStatus.todoCount), 'todo') : '', runStatus.rejectionCount > 0 ? ' ' + colors.error(runStatus.rejectionCount, 'unhandled', plur('rejection', runStatus.rejectionCount)) : '', diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index 8a6e50c7b..1fdfc9664 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -228,6 +228,29 @@ test('results with passing tests', function (t) { t.end(); }); +test('results with passing known failure tests', function (t) { + var reporter = createReporter(); + var runStatus = createRunStatus(); + runStatus.passCount = 1; + runStatus.knownFailureCount = 1; + runStatus.knownFailures = [{title: 'known failure', failing: true}]; + + var actualOutput = reporter.finish(runStatus); + var expectedOutput = [ + '', + ' ' + chalk.green('1 test passed') + time, + ' ' + chalk.red('1 test known failure'), + '', + '', + ' ' + chalk.red('1. known failure'), + '', + '' + ].join('\n'); + + t.is(actualOutput, expectedOutput); + t.end(); +}); + test('results with skipped tests', function (t) { var reporter = createReporter(); var runStatus = createRunStatus(); From 4be62efdfbb89e3edfe0a70bebb8eb6aebdcb9e7 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 18:10:27 +0800 Subject: [PATCH 16/27] remove unnecessary empty line output in verbose reporter for known failure --- lib/reporters/verbose.js | 2 +- test/reporters/verbose.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index ac1d4b5aa..f0d7a4fc5 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -96,7 +96,7 @@ VerboseReporter.prototype.finish = function (runStatus) { if (runStatus.knownFailureCount > 0) { runStatus.knownFailures.forEach(function (test) { i++; - output += '\n\n\n ' + colors.error(i + '.', test.title) + '\n'; + output += '\n\n\n ' + colors.error(i + '.', test.title); }); } diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index 1fdfc9664..af4dec7bb 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -243,7 +243,6 @@ test('results with passing known failure tests', function (t) { '', '', ' ' + chalk.red('1. known failure'), - '', '' ].join('\n'); From 0624cf3c38e2602466fb19e32079cd9929d4b6f8 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Fri, 20 May 2016 18:13:05 +0800 Subject: [PATCH 17/27] verify no reason for known failure. --- test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.js b/test/test.js index 9edcc441f..09efdeb64 100644 --- a/test/test.js +++ b/test/test.js @@ -628,6 +628,7 @@ test('failing callback tests should end without error', function (t) { a.end(err); }).run().then(function (result) { t.is(result.passed, true); + t.is(result.reason, undefined); t.end(); }); }); From dd92262c6906a1c1aef27e7f70d77245efdec64b Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Sun, 22 May 2016 15:53:16 +0800 Subject: [PATCH 18/27] delete unused commented code --- lib/reporters/mini.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 6978f9c21..3b51c3a91 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -166,7 +166,6 @@ MiniReporter.prototype.finish = function (runStatus) { i++; var title = test.title; - // var description = JSON.stringify(test); status += '\n\n\n ' + colors.error(i + '.', title); // TODO output description with link From bb7867d7948c4ae66d672461d1614e807767fc29 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Sun, 22 May 2016 20:06:26 +0800 Subject: [PATCH 19/27] remove time --- test/reporters/mini.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 5103a69c0..c55813d75 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -217,7 +217,7 @@ test('results with passing known failure tests', function (t) { }; var actualOutput = reporter.finish(runStatus); var expectedOutput = [ - '\n ' + chalk.green('1 passed') + time, + '\n ' + chalk.green('1 passed'), ' ' + chalk.red('1 known failure'), '', '', From 5f67b2adf4accd726293cb132fee646173d1f0af Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 13:39:08 +0800 Subject: [PATCH 20/27] plur failure --- lib/reporters/mini.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/mini.js b/lib/reporters/mini.js index 3b51c3a91..7f7c8cbbb 100644 --- a/lib/reporters/mini.js +++ b/lib/reporters/mini.js @@ -124,7 +124,7 @@ MiniReporter.prototype.unhandledError = function (err) { MiniReporter.prototype.reportCounts = function (time) { var lines = [ this.passCount > 0 ? '\n ' + colors.pass(this.passCount, 'passed') : '', - this.knownFailureCount > 0 ? '\n ' + colors.error(this.knownFailureCount, 'known failure') : '', + this.knownFailureCount > 0 ? '\n ' + colors.error(this.knownFailureCount, plur('known failure', this.knownFailureCount)) : '', this.failCount > 0 ? '\n ' + colors.error(this.failCount, 'failed') : '', this.skipCount > 0 ? '\n ' + colors.skip(this.skipCount, 'skipped') : '', this.todoCount > 0 ? '\n ' + colors.todo(this.todoCount, 'todo') : '' From 7066b2a898097e950b3b7ebea5c444d33b47a36c Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 13:40:29 +0800 Subject: [PATCH 21/27] add a tick --- lib/reporters/verbose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index f0d7a4fc5..b489aa65d 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -34,7 +34,7 @@ VerboseReporter.prototype.test = function (test, runStatus) { } if (test.failing) { - return ' ' + colors.error(test.title); + return colors.error(figures.tick + ' ' + test.title) } if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { From 6da3cf7844602e14a3df777f5f423d31078c979d Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 13:41:30 +0800 Subject: [PATCH 22/27] 2 known failures instead of 2 tests known failure --- lib/reporters/verbose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index b489aa65d..ae313b08f 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -78,7 +78,7 @@ VerboseReporter.prototype.finish = function (runStatus) { runStatus.failCount > 0 ? ' ' + colors.error(runStatus.failCount, plur('test', runStatus.failCount), 'failed') : ' ' + colors.pass(runStatus.passCount, plur('test', runStatus.passCount), 'passed'), - runStatus.knownFailureCount > 0 ? ' ' + colors.error(runStatus.knownFailureCount, plur('test', runStatus.knownFailureCount), 'known failure') : '', + runStatus.knownFailureCount > 0 ? ' ' + colors.error(runStatus.knownFailureCount, plur('known failure', runStatus.knownFailureCount)) : '', runStatus.skipCount > 0 ? ' ' + colors.skip(runStatus.skipCount, plur('test', runStatus.skipCount), 'skipped') : '', runStatus.todoCount > 0 ? ' ' + colors.todo(runStatus.todoCount, plur('test', runStatus.todoCount), 'todo') : '', runStatus.rejectionCount > 0 ? ' ' + colors.error(runStatus.rejectionCount, 'unhandled', plur('rejection', runStatus.rejectionCount)) : '', From da4c00f038c93f7bac83282337e313204473d57e Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 13:55:58 +0800 Subject: [PATCH 23/27] fix indent --- lib/reporters/verbose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index ae313b08f..46eab3284 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -34,7 +34,7 @@ VerboseReporter.prototype.test = function (test, runStatus) { } if (test.failing) { - return colors.error(figures.tick + ' ' + test.title) + return ' ' + colors.error(figures.tick + ' ' + test.title) } if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { From 6e3a5684564e22d5c4b107d7ab399ec2e15ae215 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 15:14:49 +0800 Subject: [PATCH 24/27] add knownFailure count to blank result --- api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/api.js b/api.js index 80f6e6a1f..2b20af905 100644 --- a/api.js +++ b/api.js @@ -233,6 +233,7 @@ function getBlankResults() { stats: { testCount: 0, passCount: 0, + knownFailureCount: 0, skipCount: 0, todoCount: 0, failCount: 0 From 0142cea8ac3ce272bf92d85eed28ca4f650f8081 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 15:15:05 +0800 Subject: [PATCH 25/27] add knownFailureCount to runstatus --- lib/runner.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/runner.js b/lib/runner.js index f34632e14..250159372 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -178,6 +178,12 @@ Runner.prototype._buildStats = function () { }) .length; + stats.knownFailureCount = this.results + .filter(function (result) { + return result.passed === true && result.result.metadata.failing; + }) + .length; + stats.passCount = stats.testCount - stats.failCount - stats.skipCount - stats.todoCount; return stats; From acd0fdaf21bb6ae1a0c6707a53ba048c70fa2bc3 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 15:36:05 +0800 Subject: [PATCH 26/27] fix npm test --- lib/reporters/verbose.js | 2 +- test/reporters/mini.js | 2 +- test/reporters/verbose.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 46eab3284..970230c17 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -34,7 +34,7 @@ VerboseReporter.prototype.test = function (test, runStatus) { } if (test.failing) { - return ' ' + colors.error(figures.tick + ' ' + test.title) + return ' ' + colors.error(figures.tick + ' ' + test.title); } if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { diff --git a/test/reporters/mini.js b/test/reporters/mini.js index c55813d75..346e9c4cc 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -89,7 +89,7 @@ test('failing test', function (t) { ' ', ' ' + graySpinner + ' ' + chalk.red('failed'), '', - ' ' + chalk.red('1 failed') + ' ' + chalk.red('1 failed') + time ].join('\n'); t.is(actualOutput, expectedOutput); diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index af4dec7bb..83d5c92a4 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -97,7 +97,7 @@ test('known failure test', function (t) { failing: true }, createRunStatus()); - var expectedOutput = ' ' + chalk.red('known failure'); + var expectedOutput = ' ' + chalk.red(figures.tick) + ' ' + chalk.red('known failure'); t.is(actualOutput, expectedOutput); t.end(); @@ -239,7 +239,7 @@ test('results with passing known failure tests', function (t) { var expectedOutput = [ '', ' ' + chalk.green('1 test passed') + time, - ' ' + chalk.red('1 test known failure'), + ' ' + chalk.red('1 known failure'), '', '', ' ' + chalk.red('1. known failure'), From c2a7b4215c67ce577649a7d1558c3e92ef9ea591 Mon Sep 17 00:00:00 2001 From: cgcgbcbc Date: Mon, 23 May 2016 16:15:15 +0800 Subject: [PATCH 27/27] fix test --- lib/reporters/verbose.js | 2 +- test/reporters/mini.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 970230c17..95afb014d 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -34,7 +34,7 @@ VerboseReporter.prototype.test = function (test, runStatus) { } if (test.failing) { - return ' ' + colors.error(figures.tick + ' ' + test.title); + return ' ' + colors.error(figures.tick) + ' ' + colors.error(test.title); } if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') { diff --git a/test/reporters/mini.js b/test/reporters/mini.js index 346e9c4cc..c55813d75 100644 --- a/test/reporters/mini.js +++ b/test/reporters/mini.js @@ -89,7 +89,7 @@ test('failing test', function (t) { ' ', ' ' + graySpinner + ' ' + chalk.red('failed'), '', - ' ' + chalk.red('1 failed') + time + ' ' + chalk.red('1 failed') ].join('\n'); t.is(actualOutput, expectedOutput);