@@ -39,9 +39,9 @@ describe('Server', () => {
3939 return relative ( '.' , p ) . split ( sep ) ;
4040 } )
4141 ) . toMatchSnapshot ( ) ;
42- expect (
43- server . middleware . context . compiler . options . plugins
44- ) . toMatchSnapshot ( ) ;
42+ expect ( server . middleware . context . compiler . options . plugins ) . toEqual ( [
43+ new webpack . HotModuleReplacementPlugin ( ) ,
44+ ] ) ;
4545
4646 compiler . hooks . done . tap ( 'webpack-dev-server' , ( ) => {
4747 server . close ( done ) ;
@@ -64,9 +64,9 @@ describe('Server', () => {
6464 return relative ( '.' , p ) . split ( sep ) ;
6565 } )
6666 ) . toMatchSnapshot ( ) ;
67- expect (
68- server . middleware . context . compiler . options . plugins
69- ) . toMatchSnapshot ( ) ;
67+ expect ( server . middleware . context . compiler . options . plugins ) . toEqual ( [
68+ new webpack . HotModuleReplacementPlugin ( ) ,
69+ ] ) ;
7070
7171 compiler . hooks . done . tap ( 'webpack-dev-server' , ( ) => {
7272 server . close ( done ) ;
@@ -78,14 +78,6 @@ describe('Server', () => {
7878
7979 // issue: https://github.com/webpack/webpack-dev-server/issues/1724
8080 describe ( 'express.static.mine.types' , ( ) => {
81- beforeEach ( ( ) => {
82- jest . resetModules ( ) ;
83- } ) ;
84-
85- afterEach ( ( ) => {
86- jest . unmock ( 'express' ) ;
87- } ) ;
88-
8981 it ( "should success even if mine.types doesn't exist" , ( done ) => {
9082 jest . mock ( 'express' , ( ) => {
9183 const data = jest . requireActual ( 'express' ) ;
@@ -118,31 +110,6 @@ describe('Server', () => {
118110 } ) ;
119111 } ) ;
120112
121- describe ( 'WEBPACK_DEV_SERVER environment variable' , ( ) => {
122- const OLD_ENV = process . env ;
123-
124- beforeEach ( ( ) => {
125- // this is important - it clears the cache
126- jest . resetModules ( ) ;
127-
128- process . env = { ...OLD_ENV } ;
129-
130- delete process . env . WEBPACK_DEV_SERVER ;
131- } ) ;
132-
133- afterEach ( ( ) => {
134- process . env = OLD_ENV ;
135- } ) ;
136-
137- it ( 'should be present' , ( ) => {
138- expect ( process . env . WEBPACK_DEV_SERVER ) . toBeUndefined ( ) ;
139-
140- require ( '../../lib/Server' ) ;
141-
142- expect ( process . env . WEBPACK_DEV_SERVER ) . toBe ( true ) ;
143- } ) ;
144- } ) ;
145-
146113 describe ( 'Invalidate Callback' , ( ) => {
147114 describe ( 'Testing callback functions on calling invalidate without callback' , ( ) => {
148115 it ( 'should be `noop` (the default callback function)' , ( done ) => {
@@ -178,4 +145,29 @@ describe('Server', () => {
178145 } ) ;
179146 } ) ;
180147 } ) ;
148+
149+ describe ( 'WEBPACK_DEV_SERVER environment variable' , ( ) => {
150+ const OLD_ENV = process . env ;
151+
152+ beforeEach ( ( ) => {
153+ // this is important - it clears the cache
154+ jest . resetModules ( ) ;
155+
156+ process . env = { ...OLD_ENV } ;
157+
158+ delete process . env . WEBPACK_DEV_SERVER ;
159+ } ) ;
160+
161+ afterEach ( ( ) => {
162+ process . env = OLD_ENV ;
163+ } ) ;
164+
165+ it ( 'should be present' , ( ) => {
166+ expect ( process . env . WEBPACK_DEV_SERVER ) . toBeUndefined ( ) ;
167+
168+ require ( '../../lib/Server' ) ;
169+
170+ expect ( process . env . WEBPACK_DEV_SERVER ) . toBe ( true ) ;
171+ } ) ;
172+ } ) ;
181173} ) ;
0 commit comments