@@ -61,75 +61,21 @@ describe('ContentBase', () => {
61
61
fs . writeFileSync ( nestedFile , 'Heyo' , 'utf8' ) ;
62
62
} , 1000 ) ;
63
63
} ) ;
64
- } ) ;
65
-
66
- describe ( 'test ignoring node_modules folder by Default' , ( ) => {
67
- beforeAll ( ( done ) => {
68
- server = testServer . start ( config , {
69
- contentBase : contentBasePublic ,
70
- watchContentBase : true ,
71
- } ) ;
72
- // making sure that chokidar has read all the files
73
- server . contentBaseWatchers [ 0 ] . on ( 'ready' , ( ) => {
74
- done ( ) ;
75
- } ) ;
76
- req = request ( server . app ) ;
77
- } ) ;
78
64
79
- afterAll ( ( done ) => {
80
- testServer . close ( ( ) => {
81
- done ( ) ;
82
- } ) ;
83
- } ) ;
84
-
85
- it ( 'Should ignore node_modules & watch bar' , ( done ) => {
86
- const watchedPaths = server . contentBaseWatchers [ 0 ] . getWatched ( ) ;
87
- // check if node_modules folder is not in watched list
88
- const folderWatched = ! ! watchedPaths [
89
- path . join ( contentBasePublic , 'node_modules' )
90
- ] ;
91
- expect ( folderWatched ) . toEqual ( false ) ;
92
- // check if bar folder is in watched list
93
- expect ( watchedPaths [ path . join ( contentBasePublic , 'bar' ) ] ) . toEqual ( [
94
- 'index.html' ,
95
- ] ) ;
96
-
97
- done ( ) ;
98
- } ) ;
99
- } ) ;
100
-
101
- describe ( 'test not ignoring node_modules folder' , ( ) => {
102
- beforeAll ( ( done ) => {
103
- server = testServer . start ( config , {
104
- contentBase : contentBasePublic ,
105
- watchContentBase : true ,
106
- watchOptions : {
107
- ignored : / b a r / ,
108
- } ,
109
- } ) ;
110
- // making sure that chokidar has read all the files
111
- server . contentBaseWatchers [ 0 ] . on ( 'ready' , ( ) => {
112
- done ( ) ;
113
- } ) ;
114
- req = request ( server . app ) ;
115
- } ) ;
116
-
117
- afterAll ( ( done ) => {
118
- testServer . close ( ( ) => {
119
- done ( ) ;
120
- } ) ;
121
- } ) ;
65
+ it ( 'watch node_modules' , ( done ) => {
66
+ const filePath = path . join (
67
+ contentBasePublic ,
68
+ 'node_modules' ,
69
+ 'index.html'
70
+ ) ;
71
+ // chokidar emitted a change,
72
+ // meaning it watched the file correctly
73
+ server . contentBaseWatchers [ 0 ] . on ( 'change' , ( ) => done ( ) ) ;
122
74
123
- it ( 'Should watch node_modules & ignore bar' , ( done ) => {
124
- const watchedPaths = server . contentBaseWatchers [ 0 ] . getWatched ( ) ;
125
- // check if node_modules folder is in watched list
126
- expect (
127
- watchedPaths [ path . join ( contentBasePublic , 'node_modules' ) ]
128
- ) . toEqual ( [ 'index.html' ] ) ;
129
- // check if bar folder is not in watched list
130
- const folderWatched = ! ! watchedPaths [ path . join ( contentBasePublic , 'bar' ) ] ;
131
- expect ( folderWatched ) . toEqual ( false ) ;
132
- done ( ) ;
75
+ // change a file manually
76
+ setTimeout ( ( ) => {
77
+ fs . writeFileSync ( filePath , `${ Math . random ( ) } ` , 'utf8' ) ;
78
+ } , 1000 ) ;
133
79
} ) ;
134
80
} ) ;
135
81
0 commit comments