diff --git a/webview-ui/vitest.config.ts b/webview-ui/vitest.config.ts index b9455584bf..e61d5bda38 100644 --- a/webview-ui/vitest.config.ts +++ b/webview-ui/vitest.config.ts @@ -10,6 +10,12 @@ export default defineConfig({ silent: true, environment: "jsdom", include: ["src/**/*.spec.ts", "src/**/*.spec.tsx"], + // Add timeout configurations to prevent flaky tests in CI + testTimeout: 15000, // 15 seconds for individual tests (increased from default 5s) + hookTimeout: 10000, // 10 seconds for setup/teardown hooks + teardownTimeout: 10000, // 10 seconds for teardown + // Retry flaky tests once in CI environments + retry: process.env.CI ? 1 : 0, }, resolve: { alias: { diff --git a/webview-ui/vitest.setup.ts b/webview-ui/vitest.setup.ts index 12210f0ec2..9e361f24d6 100644 --- a/webview-ui/vitest.setup.ts +++ b/webview-ui/vitest.setup.ts @@ -66,3 +66,11 @@ afterAll(() => { console.warn = originalConsoleWarn console.info = originalConsoleInfo }) + +// Set default timeout for waitFor operations to prevent hanging +import { configure } from "@testing-library/react" + +configure({ + // Reduce default timeout for waitFor to fail faster in CI + asyncUtilTimeout: 5000, // 5 seconds instead of default 1000ms +})