@@ -48,36 +48,46 @@ test("info-verbosity-off", async done => {
48
48
"none"
49
49
] ) ;
50
50
51
- var firstTimeOutput = true ;
52
- var hash1 ;
51
+ // info-verbosity none spits the output in one go.
52
+ // So we only need to keep a track of when we change the files
53
+ // 1. Hash and other info
54
+ // 2. (file changed) Hash and other info
55
+
56
+ var chunkNumber = 0 ;
57
+ var hash1 , hash2 ;
58
+ var summary ;
53
59
54
60
webpackProc . stdout . on ( "data" , data => {
55
61
data = data . toString ( ) ;
56
-
62
+ chunkNumber ++ ;
57
63
// We get webpack output after running test
58
64
// Since we are running the webpack in watch mode, changing file will generate additional output
59
65
// First time output will be validated fully
60
66
// Hash of the The subsequent output will be tested against that of first time output
61
- if ( firstTimeOutput ) {
62
- hash1 = extractHash ( data ) ;
63
67
64
- const summary = extractSummary ( data ) ;
68
+ switch ( chunkNumber ) {
69
+ case 1 :
70
+ hash1 = extractHash ( data ) ;
71
+ summary = extractSummary ( data ) ;
72
+
73
+ expect ( summary ) . not . toContain ( "webpack is watching the files…" ) ;
74
+ expect ( summary ) . toMatchSnapshot ( ) ;
75
+
76
+ // change file
77
+ appendDataIfFileExists ( __dirname , fileToChange , "//junk-comment" ) ;
65
78
66
- expect ( summary ) . toEqual ( expect . anything ( ) ) ;
67
- expect ( summary ) . toContain ( "" ) ;
68
- expect ( summary ) . not . toContain ( "webpack is watching the files…" ) ;
69
- expect ( summary ) . toMatchSnapshot ( ) ;
79
+ break ;
80
+ case 2 :
81
+ hash2 = extractHash ( data ) ;
70
82
71
- // change file
72
- appendDataIfFileExists ( __dirname , fileToChange , "//junk-comment" ) ;
83
+ expect ( hash2 . hash ) . not . toBe ( hash1 . hash ) ;
73
84
74
- firstTimeOutput = false ;
75
- } else {
76
- const hash2 = extractHash ( data ) ;
85
+ webpackProc . kill ( ) ;
86
+ done ( ) ;
77
87
78
- expect ( hash2 . hash ) . not . toBe ( hash1 . hash ) ;
79
- webpackProc . kill ( ) ;
80
- done ( ) ;
88
+ break ;
89
+ default :
90
+ break ;
81
91
}
82
92
} ) ;
83
93
0 commit comments