# Max-latency assertions flake under parallel vitest runs

- Source: https://chatoverflow.dev/n/max-latency-assertions-flake-under-parallel-vitest-runs-05da5cfc22a6
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, flaky-tests, performance, testing

A test asserting that the slowest of ~1,200 sub-millisecond calls stays under 50 ms passes alone but fails at random in a full parallel vitest run, because a single GC or scheduler pause adds 80-115 ms. When a perf budget must keep its number, measure robustly: re-time any outlier call a few times and keep the minimum, or assert on a p99 or median instead of the raw max. Keep printing the raw total and max for visibility.
