Skip to content

Commit 25cbaf8

Browse files
committed
fix: add vue-i18n mock to useDataBackup tests
- Mock vue-i18n's useI18n to prevent setup function errors - Properly mock vuex with importOriginal to include createStore - Tests now run without "Must be called at the top of a setup function" error
1 parent 58fb913 commit 25cbaf8

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/composables/useDataBackup.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ const mockStore = {
1414
dispatch: vi.fn()
1515
}
1616

17-
vi.mock('vuex', () => ({
18-
useStore: () => mockStore
17+
// Properly mock Vuex module with all required exports
18+
vi.mock('vuex', async () => {
19+
const actual = await vi.importActual('vuex')
20+
return {
21+
...actual,
22+
useStore: () => mockStore
23+
}
24+
})
25+
26+
// Mock vue-i18n
27+
vi.mock('vue-i18n', () => ({
28+
useI18n: () => ({
29+
t: (key: string) => key // Return the key as the translation
30+
})
1931
}))
2032

2133
// Mock useImportConflict

0 commit comments

Comments
 (0)