vitest.config.mts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { defineConfig } from "vitest/config";
  2. import path from "path";
  3. import { fileURLToPath } from "url";
  4. import { svelte } from "@sveltejs/vite-plugin-svelte";
  5. import solid from "vite-plugin-solid";
  6. const __dirname = path.dirname(fileURLToPath(import.meta.url));
  7. export default defineConfig({
  8. plugins: [
  9. svelte({ hot: false }),
  10. solid({
  11. // Only transform files in the solid package to avoid interfering with React JSX
  12. include: ["packages/solid/**/*.{ts,tsx}"],
  13. }),
  14. ],
  15. resolve: {
  16. // Ensure Svelte resolves to browser bundle, not server
  17. conditions: ["browser"],
  18. // Deduplicate React, Vue, and Solid so tests don't get two copies
  19. // (pnpm strict resolution can cause packages to resolve different copies)
  20. alias: {
  21. react: path.resolve(__dirname, "node_modules/react"),
  22. "react-dom": path.resolve(__dirname, "node_modules/react-dom"),
  23. vue: path.resolve(__dirname, "packages/vue/node_modules/vue"),
  24. "solid-js": path.resolve(__dirname, "node_modules/solid-js"),
  25. },
  26. },
  27. test: {
  28. globals: true,
  29. environment: "jsdom",
  30. include: ["packages/**/*.test.ts", "packages/**/*.test.tsx"],
  31. coverage: {
  32. provider: "v8",
  33. reporter: ["text", "json", "html"],
  34. include: ["packages/*/src/**/*.{ts,tsx,svelte}"],
  35. exclude: ["**/*.test.{ts,tsx}", "**/index.ts"],
  36. },
  37. },
  38. });