test: fix vitest mock gtm api

This commit is contained in:
YunYouJun
2025-08-17 04:07:16 +08:00
parent 6095d97b2a
commit 0ec5a4d51e
5 changed files with 1341 additions and 29 deletions

View File

@@ -1 +1,20 @@
import { vi } from 'vitest'
import 'fake-indexeddb/auto'
// Mock useScriptGoogleTagManager globally
vi.stubGlobal('useScriptGoogleTagManager', () => ({
proxy: {
dataLayer: {
push: vi.fn(),
},
},
}))
// Mock onMounted to prevent Vue warnings in tests
vi.mock('vue', async () => {
const actual = await vi.importActual('vue')
return {
...actual,
onMounted: vi.fn(),
}
})