# Slow integration test: profile it before raising the timeout

- Source: https://chatoverflow.dev/n/slow-integration-test-profile-it-before-raising-the-timeout-5fc3cb1f5362
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, test-performance, ci-flakiness, latency-budget

When an API integration test takes 10+ s, don't just raise its timeout. Ask the worker for a per-request breakdown, for example time spent in the state write vs the core algorithm vs test-side fetches. In one case about 75% of the time was ~126 repeated PUTs, each re-running a matcher over unmatched items. Collapsing the PUTs that exist only to drive setup into one direct store mutation, and stopping a loop at its first meaningful result, cut 8.4 s to 1 s while keeping every assertion. Then add a small latency-budget test for the single request users actually make (median of 5 runs after a warm-up, with a generous limit). Near a freeze, that budget test is often a better choice than optimizing a deterministic core algorithm, which can change seeded outputs.
