@@ -27,11 +27,11 @@ describe('basic serve usage', () => {
27
27
}
28
28
29
29
it ( 'should work' , async ( ) => {
30
- const { stderr, stdout } = await runServe ( [ '--no-hot ' ] , __dirname ) ;
30
+ const { stderr, stdout } = await runServe ( [ '' ] , __dirname ) ;
31
31
32
32
expect ( stderr ) . toBeFalsy ( ) ;
33
33
expect ( stdout ) . toContain ( 'main.js' ) ;
34
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
34
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
35
35
} ) ;
36
36
37
37
it ( 'should work with the "--mode" option' , async ( ) => {
@@ -40,7 +40,7 @@ describe('basic serve usage', () => {
40
40
expect ( stderr ) . toBeFalsy ( ) ;
41
41
expect ( stdout ) . toContain ( 'development' ) ;
42
42
expect ( stdout ) . toContain ( 'main.js' ) ;
43
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
43
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
44
44
} ) ;
45
45
46
46
it ( 'should work with the "--mode" option #2' , async ( ) => {
@@ -49,99 +49,99 @@ describe('basic serve usage', () => {
49
49
expect ( stderr ) . toBeFalsy ( ) ;
50
50
expect ( stdout ) . toContain ( 'production' ) ;
51
51
expect ( stdout ) . toContain ( 'main.js' ) ;
52
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
52
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
53
53
} ) ;
54
54
55
- it ( 'should work with the "--mode" option #2 ' , async ( ) => {
55
+ it ( 'should work with the "--mode" option #3 ' , async ( ) => {
56
56
const { stderr, stdout } = await runServe ( [ '--mode' , 'development' ] , __dirname ) ;
57
57
58
58
expect ( stderr ) . toBeFalsy ( ) ;
59
59
expect ( stdout ) . toContain ( 'development' ) ;
60
60
expect ( stdout ) . toContain ( 'main.js' ) ;
61
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
61
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
62
62
} ) ;
63
63
64
64
it ( 'should work with the "--progress" option' , async ( ) => {
65
65
const { stderr, stdout } = await runServe ( [ '--progress' ] , __dirname ) ;
66
66
67
67
expect ( stderr ) . toContain ( 'webpack.Progress' ) ;
68
68
expect ( stdout ) . toContain ( 'main.js' ) ;
69
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
69
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
70
70
} ) ;
71
71
72
72
it ( 'should work with the "--progress" option using the "profile" value' , async ( ) => {
73
73
const { stderr, stdout } = await runServe ( [ '--progress' , 'profile' ] , __dirname ) ;
74
74
75
75
expect ( stderr ) . toContain ( 'webpack.Progress' ) ;
76
76
expect ( stdout ) . toContain ( 'main.js' ) ;
77
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
77
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
78
78
} ) ;
79
79
80
- it ( 'should work with flags' , async ( ) => {
81
- const { stderr, stdout } = await runServe ( [ '--hot' ] , __dirname ) ;
82
-
83
- expect ( stderr ) . toBeFalsy ( ) ;
84
- expect ( stdout ) . toContain ( 'main.js' ) ;
85
- expect ( stdout ) . toContain ( 'HotModuleReplacementPlugin' ) ;
86
- } ) ;
87
-
88
- it ( 'should respect the --no-color flag' , async ( ) => {
80
+ it ( 'should log help information and respect the "--no-color" option' , async ( ) => {
89
81
const { stdout, stderr } = await runServe ( [ '--help' , '--no-color' ] , __dirname ) ;
90
82
91
83
expect ( stderr ) . toBeFalsy ( ) ;
92
84
expect ( stdout ) . toContain ( usageText ) ;
93
85
expect ( stdout ) . toContain ( descriptionText ) ;
94
86
} ) ;
95
87
96
- it ( 'should not invoke info subcommand ' , async ( ) => {
88
+ it ( 'should work with the "--client-log-level" option ' , async ( ) => {
97
89
const { stdout, stderr } = await runServe ( [ '--client-log-level' , 'info' ] , testPath ) ;
98
90
99
91
expect ( stderr ) . toBeFalsy ( ) ;
100
92
expect ( stdout ) . toContain ( 'main.js' ) ;
101
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
93
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
102
94
} ) ;
103
95
104
- it ( 'compiles without flags ' , async ( ) => {
96
+ it ( 'should work with the "--port" option ' , async ( ) => {
105
97
const { stdout, stderr } = await runServe ( [ '--port' , port ] , testPath ) ;
106
98
107
99
expect ( stderr ) . toBeFalsy ( ) ;
108
100
expect ( stdout ) . toContain ( 'main.js' ) ;
109
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
101
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toBeNull ( ) ;
110
102
} ) ;
111
103
112
- it ( 'uses hot flag to alter bundle ' , async ( ) => {
113
- const { stdout , stderr } = await runServe ( [ '--port' , port , '-- hot'] , testPath ) ;
104
+ it ( 'should work with the "--hot" option ' , async ( ) => {
105
+ const { stderr , stdout } = await runServe ( [ '--hot' ] , __dirname ) ;
114
106
115
107
expect ( stderr ) . toBeFalsy ( ) ;
116
108
expect ( stdout ) . toContain ( 'main.js' ) ;
117
- expect ( stdout ) . toContain ( ' HotModuleReplacementPlugin' ) ;
109
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toHaveLength ( 1 ) ;
118
110
} ) ;
119
111
120
- it ( 'uses hot-only flag to alter bundle' , async ( ) => {
112
+ it ( 'should work with the "--no-hot" option' , async ( ) => {
113
+ const { stdout, stderr } = await runServe ( [ '--port' , port , '--no-hot' ] , testPath ) ;
114
+
115
+ expect ( stderr ) . toBeFalsy ( ) ;
116
+ expect ( stdout ) . toContain ( 'main.js' ) ;
117
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g) ) . toBeNull ( ) ;
118
+ } ) ;
119
+
120
+ it ( 'should work with the "--hot" option using the "only" value' , async ( ) => {
121
121
const { stdout, stderr } = await runServe ( [ '--port' , port , isDevServer4 ? '--hot only' : '--hot-only' ] , testPath ) ;
122
122
123
123
expect ( stderr ) . toBeFalsy ( ) ;
124
124
expect ( stdout ) . toContain ( 'main.js' ) ;
125
- expect ( stdout ) . toContain ( ' HotModuleReplacementPlugin' ) ;
125
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toHaveLength ( 1 ) ;
126
126
} ) ;
127
127
128
- it ( 'uses no- hot flag ' , async ( ) => {
129
- const { stdout, stderr } = await runServe ( [ '--port' , port , '--no- hot' ] , testPath ) ;
128
+ it ( 'should work with "-- hot" and "--port" options ' , async ( ) => {
129
+ const { stdout, stderr } = await runServe ( [ '--port' , port , '--hot' ] , testPath ) ;
130
130
131
131
expect ( stderr ) . toBeFalsy ( ) ;
132
132
expect ( stdout ) . toContain ( 'main.js' ) ;
133
- expect ( stdout ) . not . toContain ( ' HotModuleReplacementPlugin' ) ;
133
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toHaveLength ( 1 ) ;
134
134
} ) ;
135
135
136
- it ( 'uses hot flag and progress flag ' , async ( ) => {
136
+ it ( 'should work with the "--hot" and "-- progress" options ' , async ( ) => {
137
137
const { stdout, stderr } = await runServe ( [ '--port' , port , '--hot' , '--progress' ] , testPath ) ;
138
138
139
139
expect ( stderr ) . toContain ( 'webpack.Progress' ) ;
140
140
expect ( stdout ) . toContain ( 'main.js' ) ;
141
- expect ( stdout ) . toContain ( ' HotModuleReplacementPlugin' ) ;
141
+ expect ( stdout . match ( / H o t M o d u l e R e p l a c e m e n t P l u g i n / g ) ) . toHaveLength ( 1 ) ;
142
142
} ) ;
143
143
144
- it ( 'throws error on unknown flag' , async ( ) => {
144
+ it ( 'should log and error on unknown flag' , async ( ) => {
145
145
const { exitCode, stdout, stderr } = await runServe ( [ '--port' , port , '--unknown-flag' ] , testPath ) ;
146
146
147
147
expect ( exitCode ) . toBe ( 2 ) ;
0 commit comments