@@ -16,6 +16,54 @@ const allStats = [
1616] ;
1717
1818describe ( 'Server' , ( ) => {
19+ // issue: https://github.com/webpack/webpack-dev-server/issues/1724
20+ describe ( 'express.static.mine.types' , ( ) => {
21+ beforeEach ( ( ) => {
22+ jest . resetModules ( ) ;
23+ } ) ;
24+
25+ afterEach ( ( ) => {
26+ jest . unmock ( 'express' ) ;
27+ } ) ;
28+
29+ it ( "should succeed even if mine.types doesn't exist" , ( ) => {
30+ const Server = require ( '../lib/Server' ) ;
31+
32+ jest . mock ( 'express' , ( ) => {
33+ const data = jest . requireActual ( 'express' ) ;
34+ const { static : st } = data ;
35+ const { mime } = st ;
36+
37+ delete mime . types ;
38+
39+ expect ( typeof mime . types ) . toEqual ( 'undefined' ) ;
40+
41+ return Object . assign ( data , {
42+ static : Object . assign ( st , {
43+ mime,
44+ } ) ,
45+ } ) ;
46+ } ) ;
47+
48+ return new Promise ( ( res ) => {
49+ const compiler = webpack ( config ) ;
50+ const server = new Server ( compiler ) ;
51+
52+ compiler . hooks . done . tap ( 'webpack-dev-server' , ( s ) => {
53+ const output = server . getStats ( s ) ;
54+ expect ( output . errors . length ) . toEqual ( 0 ) ;
55+
56+ server . close ( ( ) => {
57+ res ( ) ;
58+ } ) ;
59+ } ) ;
60+
61+ compiler . run ( ( ) => { } ) ;
62+ server . listen ( 8080 , 'localhost' ) ;
63+ } ) ;
64+ } ) ;
65+ } ) ;
66+
1967 it ( 'should cascade warningsFilter' , ( ) => {
2068 const stats = { warningsFilter : 'test' } ;
2169 return new Promise ( ( res ) => {
0 commit comments