@@ -166,6 +166,73 @@ describe("hot option", () => {
166
166
} ) ;
167
167
} ) ;
168
168
169
+ describe ( "simple config with already added HMR plugin" , ( ) => {
170
+ let loggerWarnSpy ;
171
+ let getInfrastructureLoggerSpy ;
172
+ let compiler ;
173
+
174
+ beforeEach ( ( ) => {
175
+ compiler = webpack ( {
176
+ ...config ,
177
+ devServer : { hot : false } ,
178
+ plugins : [ ...config . plugins , new webpack . HotModuleReplacementPlugin ( ) ] ,
179
+ } ) ;
180
+
181
+ loggerWarnSpy = jest . fn ( ) ;
182
+
183
+ getInfrastructureLoggerSpy = jest
184
+ . spyOn ( compiler , "getInfrastructureLogger" )
185
+ . mockImplementation ( ( ) => {
186
+ return {
187
+ warn : loggerWarnSpy ,
188
+ info : ( ) => { } ,
189
+ log : ( ) => { } ,
190
+ } ;
191
+ } ) ;
192
+ } ) ;
193
+
194
+ afterEach ( ( ) => {
195
+ getInfrastructureLoggerSpy . mockRestore ( ) ;
196
+ loggerWarnSpy . mockRestore ( ) ;
197
+ } ) ;
198
+
199
+ it ( "should show warning with hot normalized as true" , async ( ) => {
200
+ server = new Server ( { port } , compiler ) ;
201
+
202
+ await server . start ( ) ;
203
+
204
+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
205
+ `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`
206
+ ) ;
207
+
208
+ await server . stop ( ) ;
209
+ } ) ;
210
+
211
+ it ( `should show warning with "hot: true"` , async ( ) => {
212
+ server = new Server ( { port, hot : true } , compiler ) ;
213
+
214
+ await server . start ( ) ;
215
+
216
+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
217
+ `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`
218
+ ) ;
219
+
220
+ await server . stop ( ) ;
221
+ } ) ;
222
+
223
+ it ( `should show warning with "hot: false"` , async ( ) => {
224
+ server = new Server ( { port, hot : false } , compiler ) ;
225
+
226
+ await server . start ( ) ;
227
+
228
+ expect ( loggerWarnSpy ) . not . toHaveBeenCalledWith (
229
+ `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`
230
+ ) ;
231
+
232
+ await server . stop ( ) ;
233
+ } ) ;
234
+ } ) ;
235
+
169
236
describe ( "multi compiler hot config HMR plugin" , ( ) => {
170
237
it ( "should register the HMR plugin before compilation is complete" , async ( ) => {
171
238
let pluginFound = false ;
0 commit comments