-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
Description
Environment
Nuxt project info:
| Operating system | Linux 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 |
| CPU | Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (8 cores) |
| Node.js version | v20.19.1 |
| nuxt/cli version | 3.32.0 |
| Package manager | npm@10.8.2 |
| Nuxt version | 4.2.2 |
| Nitro version | 2.13.1 |
| Builder | vite@7.3.1 |
| Config | compatibilityDate, devtools |
| Modules | - |
Reproduction
Describe the bug
import { it, expect, vi } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
const mocks = vi.hoisted(() => ({
useAMock: vi.fn(() => 'mock-2'),
}))
mockNuxtImport('useA', () => mocks.useAMock)
it('mocking', () => {
expect(useA()).toBe('mock-2')
})fails with the following error
❯ test/2-failure.spec.ts (1 test | 1 failed) 8ms
× mocking 6ms
→ useA is not a function
Additional context
No response