@@ -3,7 +3,7 @@ import * as common from '../common/index.mjs';
3
3
import { describe , it } from 'node:test' ;
4
4
import assert from 'node:assert' ;
5
5
import { spawn } from 'node:child_process' ;
6
- import { writeFileSync , unlinkSync } from 'node:fs' ;
6
+ import { writeFile , unlink } from 'node:fs/promises ' ;
7
7
import util from 'internal/util' ;
8
8
import tmpdir from '../common/tmpdir.js' ;
9
9
@@ -46,8 +46,12 @@ test('test to delete has ran');`,
46
46
const fixturePaths = Object . fromEntries ( Object . keys ( fixtureContent )
47
47
. map ( ( file ) => [ file , tmpdir . resolve ( file ) ] ) ) ;
48
48
49
- Object . entries ( fixtureContent )
50
- . forEach ( ( [ file , content ] ) => writeFileSync ( fixturePaths [ file ] , content ) ) ;
49
+ async function setupFixtures ( ) {
50
+ await Promise . all ( Object . entries ( fixtureContent )
51
+ . map ( ( [ file , content ] ) => writeFile ( fixturePaths [ file ] , content ) ) ) ;
52
+ }
53
+
54
+ await setupFixtures ( ) ;
51
55
52
56
describe ( 'test runner watch mode with more complex setup' , ( ) => {
53
57
it ( 'should run tests when a dependency changed after a watched test file being deleted' , async ( ) => {
@@ -76,14 +80,14 @@ describe('test runner watch mode with more complex setup', () => {
76
80
runs . push ( currentRun ) ;
77
81
currentRun = '' ;
78
82
const fileToDeletePathLocal = tmpdir . resolve ( 'test-to-delete.mjs' ) ;
79
- await new Promise ( ( resolve ) => setTimeout ( ( ) => {
80
- unlinkSync ( fileToDeletePathLocal ) ;
83
+ await new Promise ( ( resolve ) => setTimeout ( async ( ) => {
84
+ await unlink ( fileToDeletePathLocal ) ;
81
85
resolve ( ) ;
82
86
} , common . platformTimeout ( 1000 ) ) ) ;
83
87
84
88
const content = fixtureContent [ 'dependency.mjs' ] ;
85
89
const path = fixturePaths [ 'dependency.mjs' ] ;
86
- setTimeout ( ( ) => writeFileSync ( path , content ) , common . platformTimeout ( 1000 ) ) ;
90
+ setTimeout ( async ( ) => await writeFile ( path , content ) , common . platformTimeout ( 1000 ) ) ;
87
91
await ran2 . promise ;
88
92
runs . push ( currentRun ) ;
89
93
currentRun = '' ;
@@ -103,4 +107,4 @@ describe('test runner watch mode with more complex setup', () => {
103
107
assert . match ( secondRun , / f a i l 0 / ) ;
104
108
assert . match ( secondRun , / c a n c e l l e d 0 / ) ;
105
109
} ) ;
106
- } ) ;
110
+ } ) ;
0 commit comments