@@ -64,6 +64,81 @@ describe('ContentBase', () => {
64
64
} , 1000 ) ;
65
65
} ) ;
66
66
} ) ;
67
+
68
+ describe ( 'test ignoring node_modules folder by Default' , ( ) => {
69
+ jest . setTimeout ( 30000 ) ;
70
+
71
+ beforeAll ( ( done ) => {
72
+ server = helper . start ( config , {
73
+ contentBase : contentBasePublic ,
74
+ watchContentBase : true ,
75
+ } ) ;
76
+ // making sure that chokidar has read all the files
77
+ server . contentBaseWatchers [ 0 ] . on ( 'ready' , ( ) => {
78
+ done ( ) ;
79
+ } ) ;
80
+ req = request ( server . app ) ;
81
+ } ) ;
82
+
83
+ afterAll ( ( done ) => {
84
+ helper . close ( ( ) => {
85
+ done ( ) ;
86
+ } ) ;
87
+ } ) ;
88
+
89
+ it ( 'Should ignore node_modules & watch bar' , ( done ) => {
90
+ const watchedPaths = server . contentBaseWatchers [ 0 ] . getWatched ( ) ;
91
+ // check if node_modules folder is not in watched list
92
+ const folderWatched = ! ! watchedPaths [
93
+ path . join ( contentBasePublic , 'node_modules' )
94
+ ] ;
95
+ expect ( folderWatched ) . toEqual ( false ) ;
96
+ // check if bar folder is in watched list
97
+ expect ( watchedPaths [ path . join ( contentBasePublic , 'bar' ) ] ) . toEqual ( [
98
+ 'index.html' ,
99
+ ] ) ;
100
+
101
+ done ( ) ;
102
+ } ) ;
103
+ } ) ;
104
+
105
+ describe ( 'test not ignoring node_modules folder' , ( ) => {
106
+ jest . setTimeout ( 30000 ) ;
107
+
108
+ beforeAll ( ( done ) => {
109
+ server = helper . start ( config , {
110
+ contentBase : contentBasePublic ,
111
+ watchContentBase : true ,
112
+ watchOptions : {
113
+ ignored : / b a r / ,
114
+ } ,
115
+ } ) ;
116
+ // making sure that chokidar has read all the files
117
+ server . contentBaseWatchers [ 0 ] . on ( 'ready' , ( ) => {
118
+ done ( ) ;
119
+ } ) ;
120
+ req = request ( server . app ) ;
121
+ } ) ;
122
+
123
+ afterAll ( ( done ) => {
124
+ helper . close ( ( ) => {
125
+ done ( ) ;
126
+ } ) ;
127
+ } ) ;
128
+
129
+ it ( 'Should watch node_modules & ignore bar' , ( done ) => {
130
+ const watchedPaths = server . contentBaseWatchers [ 0 ] . getWatched ( ) ;
131
+ // check if node_modules folder is in watched list
132
+ expect (
133
+ watchedPaths [ path . join ( contentBasePublic , 'node_modules' ) ]
134
+ ) . toEqual ( [ 'index.html' ] ) ;
135
+ // check if bar folder is not in watched list
136
+ const folderWatched = ! ! watchedPaths [ path . join ( contentBasePublic , 'bar' ) ] ;
137
+ expect ( folderWatched ) . toEqual ( false ) ;
138
+ done ( ) ;
139
+ } ) ;
140
+ } ) ;
141
+
67
142
describe ( 'test listing files in folders without index.html using the option serveIndex:false' , ( ) => {
68
143
beforeAll ( ( done ) => {
69
144
server = helper . start (
0 commit comments