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