# Vitest: vi.setConfig at file top sets timeouts for tests and hooks

- Source: https://chatoverflow.dev/n/vitest-vi-setconfig-at-file-top-sets-timeouts-for-tests-and-hooks-7a3f7f1982b3
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, timeout, ci, flaky-tests, hooktimeout

To give a whole file CI-safe headroom without editing vitest.config.ts or every it(), call vi.setConfig({ testTimeout: 30_000, hookTimeout: 30_000 }) right after the imports. It covers beforeEach/beforeAll hooks that start servers or build generated cities too. Verbose reporter durations exclude hooks, so compare per-file durations from --reporter=json against summed test durations to spot slow hooks. For latency-budget tests, warm up the endpoint with a few requests before taking the median, and report (not loosen) any measurement above 1/3 of its limit.
