2
2
3
3
const path = require ( 'path' ) ;
4
4
const fs = require ( 'graceful-fs' ) ;
5
+ const chokidar = require ( 'chokidar' ) ;
5
6
const testServer = require ( '../helpers/test-server' ) ;
6
7
const config = require ( '../fixtures/contentbase-config/webpack.config' ) ;
7
8
const port = require ( '../ports-map' ) [ 'watchFiles-option' ] ;
@@ -277,6 +278,8 @@ describe("'watchFiles' option", () => {
277
278
describe ( 'should work with options' , ( ) => {
278
279
const file = path . join ( watchDir , 'assets/example.txt' ) ;
279
280
281
+ const chokidarMock = jest . spyOn ( chokidar , 'watch' ) ;
282
+
280
283
beforeAll ( ( done ) => {
281
284
server = testServer . start (
282
285
config ,
@@ -285,6 +288,7 @@ describe("'watchFiles' option", () => {
285
288
paths : file ,
286
289
options : {
287
290
usePolling : true ,
291
+ interval : 400 ,
288
292
} ,
289
293
} ,
290
294
port,
@@ -298,6 +302,21 @@ describe("'watchFiles' option", () => {
298
302
fs . truncateSync ( file ) ;
299
303
} ) ;
300
304
305
+ it ( 'should pass correct options to chokidar config' , ( ) => {
306
+ expect ( chokidarMock ) . toHaveBeenCalledWith ( file , {
307
+ ignoreInitial : true ,
308
+ persistent : true ,
309
+ followSymlinks : false ,
310
+ atomic : false ,
311
+ alwaysStat : true ,
312
+ ignorePermissionErrors : true ,
313
+ // eslint-disable-next-line no-undefined
314
+ ignored : undefined ,
315
+ usePolling : true ,
316
+ interval : 400 ,
317
+ } ) ;
318
+ } ) ;
319
+
301
320
it ( 'should reload on file content changed' , ( done ) => {
302
321
server . staticWatchers [ 0 ] . on ( 'change' , ( changedPath ) => {
303
322
expect ( changedPath ) . toBe ( file ) ;
0 commit comments