Files
pleno-vue/vitest.config.js
Jeppe B 4810e113f3 fix(test): polyfill localStorage and align jsdom env for spec files (#267)
Switches `vitest.config.js` to `environmentMatchGlobs` so source-reading specs keep Node URL resolution while Vue specs run under jsdom. Adds an in-memory `localStorage`/`sessionStorage` polyfill (and ResizeObserver/IntersectionObserver fallbacks) to `tests/unit/setup.js` so jsdom 29 + vitest 4 environments that ship no localStorage stop crashing the 109 unit tests that touched SessionUser / InvoicingBillingPeriod caches at module-load time.

Test result: 1343/1343 fast + 1688/1688 serial pass (was 1195/1304 on master). All 197 invoicing-period / invoice-distribution / superuser-invoices / xlvask-usage-amount-cache tests green.
2026-08-09 15:40:29 +00:00

38 lines
1.0 KiB
JavaScript

import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vitest/config";
import vue from "@vitejs/plugin-vue";
import VueJsx from "@vitejs/plugin-vue-jsx";
export default defineConfig({
plugins: [vue(), VueJsx()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
quietDeps: true,
silenceDeprecations: ["import", "global-builtin", "legacy-js-api", "if-function"],
},
},
},
test: {
// Default to node so the many source-reading specs keep working. Specs
// that mount Vue components opt into jsdom via a file-level
// `// @vitest-environment jsdom` pragma, which still gets the polyfills
// below because the env config keys match.
environment: "node",
environmentMatchGlobs: [
["tests/unit/**/*.spec.js", "jsdom"],
],
include: ["tests/unit/**/*.spec.js"],
setupFiles: ["./tests/unit/setup.js"],
coverage: {
enabled: false,
},
},
});