@@ -16,9 +16,10 @@ import { resolveOptions, RoutesFolderOption } from '../options'
16
16
import pathe from 'pathe'
17
17
import fs from 'node:fs'
18
18
import { tmpdir } from 'node:os'
19
+ import { delay } from '../../tests/utils'
19
20
20
21
const FIXTURES_ROOT = pathe . resolve (
21
- pathe . join ( tmpdir ( ) , 'chokidar -' + Date . now ( ) )
22
+ pathe . join ( tmpdir ( ) , 'vue-router -' + Date . now ( ) )
22
23
)
23
24
24
25
const TEST_TIMEOUT = 4000
@@ -29,7 +30,7 @@ describe('RoutesFolderWatcher', () => {
29
30
} )
30
31
31
32
// keep track of all watchers to close them after the tests
32
- const watcherList : RoutesFolderWatcher [ ] = [ ]
33
+ let watcherList : RoutesFolderWatcher [ ] = [ ]
33
34
let testId = 0
34
35
function createWatcher ( routesFolderOptions : RoutesFolderOption ) {
35
36
const rootDir = pathe . join ( FIXTURES_ROOT , `test-${ testId ++ } ` )
@@ -49,6 +50,7 @@ describe('RoutesFolderWatcher', () => {
49
50
50
51
afterAll ( async ( ) => {
51
52
await Promise . all ( watcherList . map ( ( watcher ) => watcher . close ( ) ) )
53
+ watcherList = [ ]
52
54
} )
53
55
54
56
function waitForSpy ( ...spies : Mock [ ] ) {
@@ -81,6 +83,7 @@ describe('RoutesFolderWatcher', () => {
81
83
watcher . on ( 'change' , add )
82
84
83
85
expect ( add ) . toHaveBeenCalledTimes ( 0 )
86
+ await delay ( 200 )
84
87
85
88
fs . writeFileSync ( pathe . join ( srcDir , 'a.vue' ) , '' , 'utf-8' )
86
89
0 commit comments