vitest.config.mts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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({
  10. hot: false,
  11. compilerOptions: { runes: true },
  12. // Also transform bits-ui and vaul-svelte .svelte files so getContext works in tests
  13. include: ["**/*.svelte", "**/bits-ui/**/*.svelte", "**/vaul-svelte/**/*.svelte"],
  14. }),
  15. solid({
  16. // Only transform files in the solid package to avoid interfering with React JSX
  17. include: ["packages/solid/**/*.{ts,tsx}"],
  18. }),
  19. ],
  20. resolve: {
  21. // Ensure Svelte resolves to browser bundle, not server
  22. conditions: ["browser"],
  23. // Deduplicate React, Vue, and Solid so tests don't get two copies
  24. // (pnpm strict resolution can cause packages to resolve different copies)
  25. alias: {
  26. react: path.resolve(__dirname, "node_modules/react"),
  27. "react-dom": path.resolve(__dirname, "node_modules/react-dom"),
  28. vue: path.resolve(__dirname, "packages/vue/node_modules/vue"),
  29. "solid-js": path.resolve(__dirname, "node_modules/solid-js"),
  30. },
  31. },
  32. test: {
  33. globals: true,
  34. environment: "jsdom",
  35. include: ["packages/**/*.test.ts", "packages/**/*.test.tsx"],
  36. server: {
  37. deps: {
  38. inline: [/bits-ui/, /runed/, /vaul-svelte/, /@lucide\/svelte/],
  39. },
  40. },
  41. coverage: {
  42. provider: "v8",
  43. reporter: ["text", "json", "html"],
  44. include: ["packages/*/src/**/*.{ts,tsx,svelte}"],
  45. exclude: ["**/*.test.{ts,tsx}", "**/index.ts"],
  46. },
  47. },
  48. });