Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: disable isolate for unit test #17448

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add retry
  • Loading branch information
bluwy committed Jun 12, 2024
commit 62bdf6fa60080f8de4fd468048727749867289f6
34 changes: 25 additions & 9 deletions packages/vite/src/node/server/__tests__/watcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,30 @@ describe('watcher configuration', () => {
)
server = await createServer({ root })
await new Promise((resolve) => server!.watcher.once('ready', resolve))
const watchedDirs = Object.keys(server.watcher.getWatched())
expect(watchedDirs).toEqual(
expect.arrayContaining([
root,
resolve(root, '../config-deps'),
resolve(root, '../custom-env'),
resolve(root, '../custom-public'),
]),
)
// At this point, there's still a chance that chokidar has not watch all the necessary directories yet
// so we have to retry here for a bit
await withRetry(() => {
bluwy marked this conversation as resolved.
Show resolved Hide resolved
const watchedDirs = Object.keys(server!.watcher.getWatched())
expect(watchedDirs).toEqual(
expect.arrayContaining([
root,
resolve(root, '../config-deps'),
resolve(root, '../custom-env'),
resolve(root, '../custom-public'),
]),
)
})
})
})

async function withRetry(func: () => Promise<void> | void): Promise<void> {
const maxTries = process.env.CI ? 3 : 1
for (let tries = 0; tries < maxTries; tries++) {
try {
await func()
return
} catch {}
await new Promise((r) => setTimeout(r, 50))
}
await func()
}
Loading