@@ -15,17 +15,11 @@ import type {ReporterOnStartOptions} from 'types/Reporters';
1515
1616import chalk from 'chalk' ;
1717import BaseReporter from './base_reporter' ;
18- import { getSummary , pluralize } from './utils' ;
18+ import { getSummary } from './utils' ;
1919import getResultHeader from './get_result_header' ;
20+ import getSnapshotSummary from './get_snapshot_summary' ;
2021import testPathPatternToRegExp from '../test_path_pattern_to_regexp' ;
2122
22- const ARROW = ' \u203A ' ;
23- const FAIL_COLOR = chalk . bold . red ;
24- const SNAPSHOT_ADDED = chalk . bold . green ;
25- const SNAPSHOT_NOTE = chalk . dim ;
26- const SNAPSHOT_REMOVED = chalk . bold . red ;
27- const SNAPSHOT_SUMMARY = chalk . bold ;
28- const SNAPSHOT_UPDATED = chalk . bold . green ;
2923const TEST_SUMMARY_THRESHOLD = 20 ;
3024
3125const NPM_EVENTS = new Set ( [
@@ -149,63 +143,8 @@ class SummaryReporter extends BaseReporter {
149143 updateCommand = 're-run with `-u`' ;
150144 }
151145
152- this . log ( SNAPSHOT_SUMMARY ( 'Snapshot Summary' ) ) ;
153- if ( snapshots . added ) {
154- this . log (
155- SNAPSHOT_ADDED ( ARROW + pluralize ( 'snapshot' , snapshots . added ) ) +
156- ` written in ${ pluralize ( 'test suite' , snapshots . filesAdded ) } .` ,
157- ) ;
158- }
159-
160- if ( snapshots . unmatched ) {
161- this . log (
162- FAIL_COLOR ( ARROW + pluralize ( 'snapshot test' , snapshots . unmatched ) ) +
163- ` failed in ` +
164- `${ pluralize ( 'test suite' , snapshots . filesUnmatched ) } . ` +
165- SNAPSHOT_NOTE (
166- 'Inspect your code changes or ' +
167- updateCommand +
168- ' to update them.' ,
169- ) ,
170- ) ;
171- }
172-
173- if ( snapshots . updated ) {
174- this . log (
175- SNAPSHOT_UPDATED ( ARROW + pluralize ( 'snapshot' , snapshots . updated ) ) +
176- ` updated in ${ pluralize ( 'test suite' , snapshots . filesUpdated ) } .` ,
177- ) ;
178- }
179-
180- if ( snapshots . filesRemoved ) {
181- this . log (
182- SNAPSHOT_REMOVED (
183- ARROW + pluralize ( 'obsolete snapshot file' , snapshots . filesRemoved ) ,
184- ) +
185- ( snapshots . didUpdate
186- ? ' removed.'
187- : ' found, ' +
188- updateCommand +
189- ' to remove ' +
190- ( snapshots . filesRemoved === 1 ? 'it' : 'them.' ) +
191- '.' ) ,
192- ) ;
193- }
194-
195- if ( snapshots . unchecked ) {
196- this . log (
197- FAIL_COLOR (
198- ARROW + pluralize ( 'obsolete snapshot' , snapshots . unchecked ) ,
199- ) +
200- ( snapshots . didUpdate
201- ? ' removed.'
202- : ' found, ' +
203- updateCommand +
204- ' to remove ' +
205- ( snapshots . filesRemoved === 1 ? 'it' : 'them' ) +
206- '.' ) ,
207- ) ;
208- }
146+ const snapshotSummary = getSnapshotSummary ( snapshots , updateCommand ) ;
147+ snapshotSummary . forEach ( this . log ) ;
209148
210149 this . log ( '' ) ; // print empty line
211150 }
0 commit comments