// Replace globalThis.fetch with a stub answering from `handler(url, init)`, // which returns { status, body }. Fifteen specs carried their own copy of this // (#3109); a response shape change now has one place to go. import { vi } from 'vitest' export function stubFetch (handler) { globalThis.fetch = vi.fn(async (url, init) => { const { status, body } = handler(url, init) return { ok: status >= 200 && status < 300, status, statusText: String(status), text: async () => (body == null ? '' : JSON.stringify(body)) } }) }