mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
7dbd7811d5
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.
30 lines
614 B
TypeScript
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',
|
|
],
|
|
},
|
|
},
|
|
})
|