Skip to content

Commit b13c74f

Browse files
committed
ci: delay writing a file
1 parent 2037c37 commit b13c74f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/RoutesFolderWatcher.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import { resolveOptions, RoutesFolderOption } from '../options'
1616
import pathe from 'pathe'
1717
import fs from 'node:fs'
1818
import { tmpdir } from 'node:os'
19+
import { delay } from '../../tests/utils'
1920

2021
const FIXTURES_ROOT = pathe.resolve(
21-
pathe.join(tmpdir(), 'chokidar-' + Date.now())
22+
pathe.join(tmpdir(), 'vue-router-' + Date.now())
2223
)
2324

2425
const TEST_TIMEOUT = 4000
@@ -29,7 +30,7 @@ describe('RoutesFolderWatcher', () => {
2930
})
3031

3132
// keep track of all watchers to close them after the tests
32-
const watcherList: RoutesFolderWatcher[] = []
33+
let watcherList: RoutesFolderWatcher[] = []
3334
let testId = 0
3435
function createWatcher(routesFolderOptions: RoutesFolderOption) {
3536
const rootDir = pathe.join(FIXTURES_ROOT, `test-${testId++}`)
@@ -49,6 +50,7 @@ describe('RoutesFolderWatcher', () => {
4950

5051
afterAll(async () => {
5152
await Promise.all(watcherList.map((watcher) => watcher.close()))
53+
watcherList = []
5254
})
5355

5456
function waitForSpy(...spies: Mock[]) {
@@ -81,6 +83,7 @@ describe('RoutesFolderWatcher', () => {
8183
watcher.on('change', add)
8284

8385
expect(add).toHaveBeenCalledTimes(0)
86+
await delay(200)
8487

8588
fs.writeFileSync(pathe.join(srcDir, 'a.vue'), '', 'utf-8')
8689

0 commit comments

Comments
 (0)