Opus finding
Tests share a single response across cases; header mutation in one test could mask regressions
lowtest-gapmedium
- apps/web/middleware.test.ts:20-22
The middleware result is computed once at describe-body evaluation time and reused across every `it`. NextResponse.headers is a mutable Headers object; if any future test (or imported side effect) mutates res.headers, subsequent tests would see contaminated state. Additionally, computing `res` at describe-body evaluation runs the middleware before vitest hooks/setup, which is a subtle ordering hazard if module-level mocks are ever added.
Recommendation
Move `const res = middleware(makeReq());` into a beforeEach, or call middleware(makeReq()) inside each `it` block, to ensure isolation.