@@ -59,8 +59,8 @@ async function testWatch(
5959 if ( runnerCwd ) args . push ( '--cwd' , runnerCwd ) ;
6060 if ( isolation ) args . push ( '--isolation' , isolation ) ;
6161 const child = spawn ( process . execPath ,
62- args ,
63- { encoding : 'utf8' , stdio : 'pipe' , cwd } ) ;
62+ args ,
63+ { encoding : 'utf8' , stdio : 'pipe' , cwd } ) ;
6464 let stdout = '' ;
6565 let currentRun = '' ;
6666 const runs = [ ] ;
@@ -103,10 +103,12 @@ async function testWatch(
103103 currentRun = '' ;
104104 const fileToRenamePath = tmpdir . resolve ( fileToUpdate ) ;
105105 const newFileNamePath = tmpdir . resolve ( `test-renamed-${ fileToUpdate } ` ) ;
106- const interval = setInterval ( ( ) => renameSync ( fileToRenamePath , newFileNamePath ) , common . platformTimeout ( 1000 ) ) ;
106+ const interval = setInterval ( ( ) => {
107+ renameSync ( fileToRenamePath , newFileNamePath ) , common . platformTimeout ( 1000 )
108+ clearInterval ( interval ) ;
109+ } ) ;
107110 await ran2 . promise ;
108111 runs . push ( currentRun ) ;
109- clearInterval ( interval ) ;
110112 child . kill ( ) ;
111113 await once ( child , 'exit' ) ;
112114
@@ -141,11 +143,11 @@ async function testWatch(
141143 unlinkSync ( fileToDeletePath ) ;
142144 } else {
143145 ran2 . resolve ( ) ;
146+ clearInterval ( interval ) ;
144147 }
145148 } , common . platformTimeout ( 1000 ) ) ;
146149 await ran2 . promise ;
147150 runs . push ( currentRun ) ;
148- clearInterval ( interval ) ;
149151 child . kill ( ) ;
150152 await once ( child , 'exit' ) ;
151153
@@ -162,15 +164,17 @@ async function testWatch(
162164 currentRun = '' ;
163165 const newFilePath = tmpdir . resolve ( fileToCreate ) ;
164166 const interval = setInterval (
165- ( ) => writeFileSync (
166- newFilePath ,
167- 'module.exports = {};'
168- ) ,
167+ ( ) => {
168+ writeFileSync (
169+ newFilePath ,
170+ 'module.exports = {};'
171+ ) ;
172+ clearInterval ( interval ) ;
173+ } ,
169174 common . platformTimeout ( 1000 )
170175 ) ;
171176 await ran2 . promise ;
172177 runs . push ( currentRun ) ;
173- clearInterval ( interval ) ;
174178 child . kill ( ) ;
175179 await once ( child , 'exit' ) ;
176180
0 commit comments