Files
程序员阿江(Relakkes) 7dbd7811d5 test(desktop): restore web storage under Node 22+
Node 22+ defines a global `localStorage` accessor that stays inert
unless the process was started with `--localstorage-file`. vitest's
jsdom environment only copies a window key onto `globalThis` when
nothing is there yet, so Node's inert stub wins over jsdom's real
Storage and `window.localStorage` reads back undefined.

Every suite whose `beforeEach` calls `localStorage.clear()` therefore
died at setup, taking the whole file with it — 12 files and 396 tests
on a clean tree, none of them a real failure. Install a Storage
implementation from a setup file so browser semantics hold regardless
of Node version.

Local desktop suite: 396 failures across 12 files -> 2 across 1.
2026-08-08 23:57:32 +08:00

30 lines
614 B
TypeScript

import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
environment: 'jsdom',
globals: true,
css: true,
setupFiles: ['./src/test/webStorage.ts'],
coverage: {
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.test.{ts,tsx}',
'src/**/*.d.ts',
'src/types/**',
'src/mocks/**',
'src/test/**',
'src/vite-env.d.ts',
],
},
},
})