File tree 2 files changed +29
-14
lines changed 2 files changed +29
-14
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import {
29
29
filterByParameters ,
30
30
filterByPlatform ,
31
31
getExpectationUpdates ,
32
+ getSuggestionsForAction ,
32
33
printSuggestions ,
33
34
readJSON ,
34
35
writeJSON ,
@@ -295,23 +296,31 @@ async function main() {
295
296
fail = true ;
296
297
console . error ( err ) ;
297
298
} finally {
299
+ const added = getSuggestionsForAction ( recommendations , 'add' ) ;
300
+ const removed = getSuggestionsForAction ( recommendations , 'remove' ) ;
301
+ const updated = getSuggestionsForAction ( recommendations , 'update' ) ;
298
302
if ( ! ! provideSuggestions ) {
299
303
printSuggestions (
300
- recommendations ,
301
- 'add' ,
304
+ added ,
302
305
'Add the following to TestExpectations.json to ignore the error:' ,
306
+ true ,
303
307
) ;
304
308
printSuggestions (
305
- recommendations ,
306
- 'remove' ,
309
+ removed ,
307
310
'Remove the following from the TestExpectations.json to ignore the error:' ,
308
311
) ;
309
312
printSuggestions (
310
- recommendations ,
311
- 'update' ,
313
+ updated ,
312
314
'Update the following expectations in the TestExpectations.json to ignore the error:' ,
315
+ true ,
313
316
) ;
314
317
}
318
+ const unexpected = added . length + removed . length + updated . length ;
319
+ console . log (
320
+ fail && Boolean ( unexpected )
321
+ ? `Run failed: ${ unexpected } unexpected result(s).`
322
+ : `Run succeeded.` ,
323
+ ) ;
315
324
process . exit ( fail ? 1 : 0 ) ;
316
325
}
317
326
}
Original file line number Diff line number Diff line change @@ -72,27 +72,33 @@ export function prettyPrintJSON(json: unknown): void {
72
72
console . log ( JSON . stringify ( json , null , 2 ) ) ;
73
73
}
74
74
75
- export function printSuggestions (
75
+ export function getSuggestionsForAction (
76
76
recommendations : RecommendedExpectation [ ] ,
77
77
action : RecommendedExpectation [ 'action' ] ,
78
- message : string ,
79
- ) : void {
80
- const toPrint = recommendations . filter ( item => {
78
+ ) : RecommendedExpectation [ ] {
79
+ return recommendations . filter ( item => {
81
80
return item . action === action ;
82
81
} ) ;
83
- if ( toPrint . length ) {
82
+ }
83
+
84
+ export function printSuggestions (
85
+ recommendations : RecommendedExpectation [ ] ,
86
+ message : string ,
87
+ printBasedOn = false ,
88
+ ) : void {
89
+ if ( recommendations . length ) {
84
90
console . log ( message ) ;
85
91
prettyPrintJSON (
86
- toPrint . map ( item => {
92
+ recommendations . map ( item => {
87
93
return item . expectation ;
88
94
} ) ,
89
95
) ;
90
- if ( action !== 'remove' ) {
96
+ if ( printBasedOn ) {
91
97
console . log (
92
98
'The recommendations are based on the following applied expectations:' ,
93
99
) ;
94
100
prettyPrintJSON (
95
- toPrint . map ( item => {
101
+ recommendations . map ( item => {
96
102
return item . basedOn ;
97
103
} ) ,
98
104
) ;
You can’t perform that action at this time.
0 commit comments