44 * This source code is licensed under the BSD-style license found in the
55 * LICENSE file in the root directory of this source tree. An additional grant
66 * of patent rights can be found in the PATENTS file in the same directory.
7+ *
8+ * @flow
79 */
810'use strict' ;
911
12+ import type { AggregatedResult , TestResult } from 'types/TestResult' ;
13+ import type { Config } from 'types/Config' ;
14+ import type { Process } from 'types/Process' ;
15+
1016const chalk = require ( 'chalk' ) ;
1117const formatFailureMessage = require ( 'jest-util' ) . formatFailureMessage ;
1218const path = require ( 'path' ) ;
1319const VerboseLogger = require ( './VerboseLogger' ) ;
1420
21+ type SnapshotSummary = {
22+ added : number ,
23+ didUpdate : boolean ,
24+ filesAdded : number ,
25+ filesRemoved : number ,
26+ filesUnmatched : number ,
27+ filesUpdated : number ,
28+ matched : number ,
29+ total : number ,
30+ unchecked : number ,
31+ unmatched : number ,
32+ updated : number ,
33+ } ;
34+
1535// Explicitly reset for these messages since they can get written out in the
1636// middle of error logging (should have listened to Spengler and not crossed the
1737// streams).
@@ -34,23 +54,31 @@ const pluralize = (word, count) => `${count} ${word}${count === 1 ? '' : 's'}`;
3454
3555class DefaultTestReporter {
3656
37- constructor ( customProcess ) {
57+ _config : Config ;
58+ _process : Process ;
59+ verboseLogger : VerboseLogger ;
60+
61+ constructor ( customProcess : Process ) {
3862 this . _process = customProcess || process ;
3963 }
4064
41- log ( string ) {
42- this . _process . stdout . write ( string + '\n' ) ;
65+ log ( message : string ) {
66+ this . _process . stdout . write ( message + '\n' ) ;
4367 }
4468
45- onRunStart ( config , results ) {
69+ onRunStart ( config : Config , results : AggregatedResult ) {
4670 this . _config = config ;
4771 this . _printWaitingOn ( results ) ;
4872 if ( this . _config . verbose ) {
4973 this . verboseLogger = new VerboseLogger ( this . _process ) ;
5074 }
5175 }
5276
53- onTestResult ( config , testResult , results ) {
77+ onTestResult (
78+ config : Config ,
79+ testResult : TestResult ,
80+ results : AggregatedResult ,
81+ ) {
5482 this . _clearWaitingOn ( ) ;
5583
5684 const pathStr =
@@ -105,7 +133,7 @@ class DefaultTestReporter {
105133 this . _printWaitingOn ( results ) ;
106134 }
107135
108- onRunComplete ( config , aggregatedResults ) {
136+ onRunComplete ( config : Config , aggregatedResults : AggregatedResult ) {
109137 const totalTestSuites = aggregatedResults . numTotalTestSuites ;
110138 const failedTests = aggregatedResults . numFailedTests ;
111139 const passedTests = aggregatedResults . numPassedTests ;
@@ -158,7 +186,7 @@ class DefaultTestReporter {
158186 return snapshotFailure ? false : aggregatedResults . success ;
159187 }
160188
161- _getSnapshotSummary ( aggregatedResults ) {
189+ _getSnapshotSummary ( aggregatedResults : AggregatedResult ) : SnapshotSummary {
162190 let added = 0 ;
163191 let filesAdded = 0 ;
164192 let filesRemoved = aggregatedResults . snapshotFilesRemoved ;
@@ -204,7 +232,7 @@ class DefaultTestReporter {
204232 } ;
205233 }
206234
207- _printSnapshotSummary ( snapshots ) {
235+ _printSnapshotSummary ( snapshots : SnapshotSummary ) {
208236 if (
209237 snapshots . added ||
210238 snapshots . filesRemoved ||
@@ -265,7 +293,7 @@ class DefaultTestReporter {
265293 }
266294 }
267295
268- _printSummary ( aggregatedResults ) {
296+ _printSummary ( aggregatedResults : AggregatedResult ) {
269297 // If there were any failing tests and there was a large number of tests
270298 // executed, re-print the failing results at the end of execution output.
271299 const failedTests = aggregatedResults . numFailedTests ;
@@ -305,7 +333,7 @@ class DefaultTestReporter {
305333 this . _process . stdout . write ( this . _config . noHighlight ? '' : '\r\x1B[K' ) ;
306334 }
307335
308- _printWaitingOn ( results ) {
336+ _printWaitingOn ( results : AggregatedResult ) {
309337 const remaining = results . numTotalTestSuites -
310338 results . numPassedTestSuites -
311339 results . numFailedTestSuites -
0 commit comments