With the help of @Kapcash, now it works. I have to use what Nuxt offer first and then Vitest. Here is what I've changed: instead of
vi.mock('#imports', async () => ({...
now I have:
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
....
const mockUser = ref<User | null>(null)
mockNuxtImport('useSanctumAuth', () => {
return () => ({
user: mockUser,
})
})
beforeEach(() => {
vi.clearAllMocks()
mockUser.value = null
})