[UnitTests] Add a mock to window.localStorage so that filter tests don't fail if using useLanguage

This commit is contained in:
Aaro Koivukangas
2026-08-19 19:39:05 +03:00
parent 1430923ec4
commit 5c2f477794
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
import { vi } from 'vitest'
// Some FilterView filter modules pull in useLanguage -> redux/auth -> apiConnection, which
// reads window.localStorage at module load time. Stub it so those modules can be imported
// under Vitest's Node test environment.
vi.stubGlobal('window', { localStorage: { getItem: () => null } })
+1
View File
@@ -11,6 +11,7 @@ export default defineConfig({
test: {
reporters: ['tree'],
exclude: ['./dist', 'node_modules'],
setupFiles: ['./tests/unit/setup.ts'],
pool: 'threads',
testTimeout: 10_000, // 10s timeout
sequence: {