-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Flowify reporters in jest-cli #1147
Closed
wbinnssmith
wants to merge
1
commit into
jestjs:master
from
wbinnssmith:wbinnssmith/flowify-reporters
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Process { | ||
stdout : stream$Writable | tty$WriteStream; | ||
exit(code? : number) : void; | ||
}; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,34 @@ | |
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
import type {AggregatedResult, TestResult} from '../../../../types/TestResult'; | ||
import type {Config} from '../../../../types/Config'; | ||
import type {Process} from '../../../../interfaces/Process'; | ||
|
||
const chalk = require('chalk'); | ||
const formatFailureMessage = require('jest-util').formatFailureMessage; | ||
const path = require('path'); | ||
const VerboseLogger = require('./VerboseLogger'); | ||
|
||
type SnapshotSummary = { | ||
added: number, | ||
didUpdate: boolean, | ||
filesAdded: number, | ||
filesRemoved: number, | ||
filesUnmatched: number, | ||
filesUpdated: number, | ||
matched: number, | ||
total: number, | ||
unchecked: number, | ||
unmatched: number, | ||
updated: number, | ||
}; | ||
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. unsure if this is worth defining 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 is awesome. Yes, it was very confusing. |
||
|
||
// Explicitly reset for these messages since they can get written out in the | ||
// middle of error logging (should have listened to Spengler and not crossed the | ||
// streams). | ||
|
@@ -34,23 +54,31 @@ const pluralize = (word, count) => `${count} ${word}${count === 1 ? '' : 's'}`; | |
|
||
class DefaultTestReporter { | ||
|
||
constructor(customProcess) { | ||
_config: Config; | ||
_process: Process; | ||
verboseLogger: VerboseLogger; | ||
|
||
constructor(customProcess: Process) { | ||
this._process = customProcess || process; | ||
} | ||
|
||
log(string) { | ||
this._process.stdout.write(string + '\n'); | ||
log(str: string) { | ||
this._process.stdout.write(str + '\n'); | ||
} | ||
|
||
onRunStart(config, results) { | ||
onRunStart(config: Config, results: AggregatedResult) { | ||
this._config = config; | ||
this._printWaitingOn(results); | ||
if (this._config.verbose) { | ||
this.verboseLogger = new VerboseLogger(this._process); | ||
} | ||
} | ||
|
||
onTestResult(config, testResult, results) { | ||
onTestResult( | ||
config: Config, | ||
testResult: TestResult, | ||
results: AggregatedResult | ||
) { | ||
this._clearWaitingOn(); | ||
|
||
const pathStr = | ||
|
@@ -105,7 +133,7 @@ class DefaultTestReporter { | |
this._printWaitingOn(results); | ||
} | ||
|
||
onRunComplete(config, aggregatedResults) { | ||
onRunComplete(config: Config, aggregatedResults: AggregatedResult) { | ||
const totalTestSuites = aggregatedResults.numTotalTestSuites; | ||
const failedTests = aggregatedResults.numFailedTests; | ||
const passedTests = aggregatedResults.numPassedTests; | ||
|
@@ -118,7 +146,7 @@ class DefaultTestReporter { | |
return true; | ||
} | ||
|
||
const snapshots = this._getSnapshotSummary(aggregatedResults); | ||
const snapshots: SnapshotSummary = this._getSnapshotSummary(aggregatedResults); | ||
const snapshotFailure = !!(!snapshots.didUpdate && ( | ||
snapshots.unchecked || | ||
snapshots.unmatched || | ||
|
@@ -158,7 +186,7 @@ class DefaultTestReporter { | |
return snapshotFailure ? false : aggregatedResults.success; | ||
} | ||
|
||
_getSnapshotSummary(aggregatedResults) { | ||
_getSnapshotSummary(aggregatedResults: AggregatedResult) { | ||
let added = 0; | ||
let filesAdded = 0; | ||
let filesRemoved = aggregatedResults.snapshotFilesRemoved; | ||
|
@@ -204,7 +232,7 @@ class DefaultTestReporter { | |
}; | ||
} | ||
|
||
_printSnapshotSummary(snapshots) { | ||
_printSnapshotSummary(snapshots: SnapshotSummary) { | ||
if ( | ||
snapshots.added || | ||
snapshots.filesRemoved || | ||
|
@@ -265,7 +293,7 @@ class DefaultTestReporter { | |
} | ||
} | ||
|
||
_printSummary(aggregatedResults) { | ||
_printSummary(aggregatedResults: AggregatedResult) { | ||
// If there were any failing tests and there was a large number of tests | ||
// executed, re-print the failing results at the end of execution output. | ||
const failedTests = aggregatedResults.numFailedTests; | ||
|
@@ -305,7 +333,7 @@ class DefaultTestReporter { | |
this._process.stdout.write(this._config.noHighlight ? '' : '\r\x1B[K'); | ||
} | ||
|
||
_printWaitingOn(results) { | ||
_printWaitingOn(results: AggregatedResult) { | ||
const remaining = results.numTotalTestSuites - | ||
results.numPassedTestSuites - | ||
results.numFailedTestSuites - | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
hope this is a good convention. let me know otherwise :)