@@ -16,6 +16,55 @@ 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 success even if mine.types doesn't exist" , ( ) => {
30+ // eslint-disable-next-line
31+ const Server = require ( '../lib/Server' ) ;
32+
33+ jest . mock ( 'express' , ( ) => {
34+ const data = jest . requireActual ( 'express' ) ;
35+ const { static : st } = data ;
36+ const { mime } = st ;
37+
38+ delete mime . types ;
39+
40+ expect ( typeof mime . types ) . toEqual ( 'undefined' ) ;
41+
42+ return Object . assign ( data , {
43+ static : Object . assign ( st , {
44+ mime,
45+ } ) ,
46+ } ) ;
47+ } ) ;
48+
49+ return new Promise ( ( res ) => {
50+ const compiler = webpack ( config ) ;
51+ const server = new Server ( compiler ) ;
52+
53+ compiler . hooks . done . tap ( 'webpack-dev-server' , ( s ) => {
54+ const output = server . getStats ( s ) ;
55+ expect ( output . errors . length ) . toEqual ( 0 ) ;
56+
57+ server . close ( ( ) => {
58+ res ( ) ;
59+ } ) ;
60+ } ) ;
61+
62+ compiler . run ( ( ) => { } ) ;
63+ server . listen ( 8080 , 'localhost' ) ;
64+ } ) ;
65+ } ) ;
66+ } ) ;
67+
1968 it ( 'should cascade warningsFilter' , ( ) => {
2069 const stats = { warningsFilter : 'test' } ;
2170 return new Promise ( ( res ) => {
0 commit comments