79301291

Date: 2024-12-22 16:25:42
Score: 1.5
Natty:
Report link

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
    })
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Kapcash
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: dust_bg