mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Node 26 defines localStorage as a native global accessor returning undefined unless started with --localstorage-file. Vitest's jsdom environment sets window === globalThis, so that accessor shadows jsdom's own, breaking all 20 test files that touch localStorage (479 tests). sessionStorage is unaffected. Install an in-memory Storage in a setup file when the global is missing. Not using --localstorage-file: it is file-backed and shared across vitest's parallel workers, which would leak state between test files. Suite: 3572/3572 passing (was 3093/3572). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { resolve } from "path";
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
"@lib": resolve(__dirname, "src/lib"),
|
|
"@stores": resolve(__dirname, "src/stores"),
|
|
"@components": resolve(__dirname, "src/components"),
|
|
"@pages": resolve(__dirname, "src/pages"),
|
|
"@styles": resolve(__dirname, "src/styles"),
|
|
},
|
|
},
|
|
test: {
|
|
environment: "jsdom",
|
|
// Restores `localStorage`, which Node 26 shadows out of the jsdom global.
|
|
setupFiles: ["./tests/setup.ts"],
|
|
// Both the `tests/**/*.test.ts` suite and component-local
|
|
// `src/**/*.test.ts` files are picked up.
|
|
include: ["tests/**/*.test.ts", "src/**/*.test.ts"],
|
|
coverage: {
|
|
provider: "v8",
|
|
include: ["src/**/*.ts"],
|
|
// Keep this list minimal and justified. An unexplained entry hides a
|
|
// real gap: window-state.ts, credentials.ts, updater.ts and
|
|
// UpdateNotifier.ts each sat here while having (or gaining) tests, so
|
|
// their coverage never showed up in any report.
|
|
exclude: [
|
|
"src/**/*.d.ts",
|
|
// App bootstrap: wires the DOM, router and stores together at startup.
|
|
// Has no seam to test below the e2e level; covered by tests/e2e.
|
|
"src/main.ts",
|
|
// Top-level page orchestrator, likewise covered at the e2e level.
|
|
// Tracked for unit coverage — remove this entry once it has tests.
|
|
"src/pages/MainPage.ts",
|
|
// RNNoise AudioWorklet host: needs a real AudioContext/WASM runtime
|
|
// that jsdom cannot provide. Exercised by tests/browser and e2e.
|
|
"src/lib/noise-suppression.ts",
|
|
],
|
|
thresholds: {
|
|
statements: 70,
|
|
branches: 70,
|
|
functions: 70,
|
|
lines: 70,
|
|
},
|
|
},
|
|
},
|
|
});
|