Apparently, I can just do it like this:
const { mockUseNuxtApp } = vi.hoisted(() => ({
mockUseNuxtApp: vi.fn(() => ({
$csrfFetch: vi.fn(),
})),
}));
mockNuxtImport('useNuxtApp', () => mockUseNuxtApp);
describe('...', () => {
afterEach(() => {
mockFetch.mockReset();
});
it('...', async () => {
mockUseNuxtApp.mockReturnValue({
$csrfFetch: vi.fn(),
});
// do somthing where $csrfFetch is used
});
});