@@ -12,8 +12,6 @@ if (common.isIBMi)
12
12
if ( common . isAIX )
13
13
common . skip ( 'folder watch capability is limited in AIX.' ) ;
14
14
15
- tmpdir . refresh ( ) ;
16
-
17
15
const { FilesWatcher } = watcher ;
18
16
19
17
tmpdir . refresh ( ) ;
@@ -32,15 +30,19 @@ Object.entries(fixtureContent)
32
30
. forEach ( ( [ file , content ] ) => writeFileSync ( fixturePaths [ file ] , content ) ) ;
33
31
34
32
describe ( 'watch file with shared dependency' , ( ) => {
35
- it ( 'should not remove shared dependencies when unfiltering an owner' , ( ) => {
33
+ it ( 'should not remove shared dependencies when unfiltering an owner' , ( t , done ) => {
36
34
const controller = new AbortController ( ) ;
37
- const watcher = new FilesWatcher ( { signal : controller . signal , debounce : 200 } ) ;
35
+ const watcher = new FilesWatcher ( {
36
+ signal : controller . signal ,
37
+ debounce : common . isMacOS ? common . platformTimeout ( 200 ) : 200
38
+ } ) ;
38
39
39
40
watcher . on ( 'changed' , ( { owners } ) => {
40
41
assert . strictEqual ( owners . size , 2 ) ;
41
42
assert . ok ( owners . has ( fixturePaths [ 'test.js' ] ) ) ;
42
43
assert . ok ( owners . has ( fixturePaths [ 'test-2.js' ] ) ) ;
43
44
controller . abort ( ) ;
45
+ done ( ) ;
44
46
} ) ;
45
47
watcher . filterFile ( fixturePaths [ 'test.js' ] ) ;
46
48
watcher . filterFile ( fixturePaths [ 'test-2.js' ] ) ;
@@ -49,6 +51,20 @@ describe('watch file with shared dependency', () => {
49
51
watcher . unfilterFilesOwnedBy ( [ fixturePaths [ 'test.js' ] ] ) ;
50
52
watcher . filterFile ( fixturePaths [ 'test.js' ] ) ;
51
53
watcher . filterFile ( fixturePaths [ 'dependency.js' ] , fixturePaths [ 'test.js' ] ) ;
52
- writeFileSync ( fixturePaths [ 'dependency.js' ] , 'module.exports = { modified: true };' ) ;
54
+
55
+ if ( common . isMacOS ) {
56
+ // Do the write with a delay to ensure that the OS is ready to notify us.
57
+ setImmediate ( ( ) => {
58
+ writeFileSync (
59
+ fixturePaths [ 'dependency.js' ] ,
60
+ 'module.exports = { modified: true };'
61
+ ) ;
62
+ } , common . platformTimeout ( 100 ) ) ;
63
+ } else {
64
+ writeFileSync (
65
+ fixturePaths [ 'dependency.js' ] ,
66
+ 'module.exports = { modified: true };'
67
+ ) ;
68
+ }
53
69
} ) ;
54
70
} ) ;
0 commit comments