import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "./vite.config"; // `vite.config.ts` exports a `defineConfig(({ mode }) => …)` callback // so the dev server can load `.env*` files through Vite's `loadEnv`. // `mergeConfig` does not accept callback-form configs, so resolve the // callback here with the same context Vitest would supply, then hand // the plain object to the merge. export default defineConfig(async (ctx) => { const resolved = typeof viteConfig === "function" ? await viteConfig(ctx) : viteConfig; return mergeConfig(resolved, { resolve: { // Force the browser entry of Svelte so `mount` is available in jsdom. conditions: ["browser"], }, test: { environment: "jsdom", include: ["tests/**/*.test.ts"], globals: true, setupFiles: ["./tests/setup.ts"], }, }); });