-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add output for failing tests #837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1f8d19
732e1c0
269007a
cb01bd3
452cb41
05a6c99
d0e5dc2
bdb5333
1d02fa5
97b9918
53b9302
7969dca
7f7160d
1352138
d618a6a
4be62ef
0624cf3
dd92262
bb7867d
5f67b2a
7066b2a
6da3cf7
da4c00f
6e3a568
0142cea
acd0fda
c2a7b42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 (test.failing && !test.error) { | ||
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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to work for me when I run your code against a test file (will post the code in a PR comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems that the results does not have that count, I grep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems it is called in api.js, but since it has knownFailures, should I just use its length? |
||
this.skipCount = sum(this.stats, 'skipCount'); | ||
this.todoCount = sum(this.stats, 'todoCount'); | ||
this.failCount = sum(this.stats, 'failCount'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(figures.tick) + ' ' + chalk.red('known failure'); | ||
|
||
t.is(actualOutput, expectedOutput); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the assertion to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think colors are the issue here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. My suggestion above will make the color chars visible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did not see your comment when I posted mine ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, fixed now |
||
t.end(); | ||
}); | ||
|
||
test('failing test', function (t) { | ||
var reporter = createReporter(); | ||
|
||
|
@@ -214,6 +228,28 @@ 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 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(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where should I write tests for this line? Seems that there is no test/run-status.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgcgbcbc, @nfcampos is running into that as well: #844 (comment).
Maybe leave that for now, focus on the reporter tests (which use stubbed data anyway).