product-context.test.tsx failed with "localStorage.clear is not a function". Root cause: Node 25 ships a global `localStorage` Web Storage stub that is non-functional without --localstorage-file, and it shadows the test DOM environment's storage. The two DOM tests also relied on `jsdom`, which was only present transitively (not a tracker-web dependency) while the rest of the monorepo standardizes on happy-dom. - Add happy-dom as a tracker-web devDependency; switch the two `@vitest-environment jsdom` tests (product-context, command-menu) to happy-dom. - Add vitest.setup.ts that installs a real in-memory Web Storage over Node 25's non-functional stub when the active localStorage/sessionStorage lacks the Storage API; wire it via test.setupFiles. Verified: full tracker-web suite 230/230 (was 228/2). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
environment: 'node',
|
|
globals: true,
|
|
setupFiles: ['./vitest.setup.ts'],
|
|
exclude: ['e2e/**', 'node_modules/**', '.next/**'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
exclude: [
|
|
'node_modules/**',
|
|
'.next/**',
|
|
'coverage/**',
|
|
'**/*.test.ts',
|
|
'**/*.test.tsx',
|
|
'**/*.config.*',
|
|
'**/e2e/**',
|
|
],
|
|
// Vitest reads these keys directly under `thresholds` (the legacy `global`
|
|
// nesting is ignored by the v8 provider and silently disables enforcement).
|
|
thresholds: {
|
|
branches: 80,
|
|
functions: 80,
|
|
lines: 80,
|
|
statements: 80,
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
// Workspace packages (e.g. @bytelyst/charts) can resolve their own React
|
|
// copy via the pnpm store; dedupe so SSR render tests use a single React
|
|
// instance (avoids the "Invalid hook call" dual-package hazard).
|
|
dedupe: ['react', 'react-dom'],
|
|
},
|
|
});
|