You wrote a mock. The test still hits the real module. Nothing in the error message points at why.
import { fetchUser } from './api'
import { vi, test, expect } from 'vitest'
const mockFetch = vi.fn()
vi.mock('./api', () => ({ fetchUser: mockFetch })) // ReferenceError






